chore(git): merge pull request #185 from fixes-1-7 into staging
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m2s

Reviewed-on: #185
This commit is contained in:
enes 2025-01-07 20:02:56 +00:00
commit cda8e1c210
3 changed files with 31 additions and 2 deletions

View File

@ -0,0 +1,11 @@
.spinner {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
-webkit-backdrop-filter: blur(1px);
backdrop-filter: blur(1px);
pointer-events: none;
}

View File

@ -8,6 +8,8 @@ import {
} from '../../controllers' } from '../../controllers'
import { errorFeedback } from '../../types' import { errorFeedback } from '../../types'
import { MediaInputPopover } from './MediaInputPopover' import { MediaInputPopover } from './MediaInputPopover'
import { Spinner } from 'components/Spinner'
import styles from './ImageUpload.module.scss'
export interface ImageUploadProps { export interface ImageUploadProps {
multiple?: boolean | undefined multiple?: boolean | undefined
@ -15,6 +17,7 @@ export interface ImageUploadProps {
} }
export const ImageUpload = React.memo( export const ImageUpload = React.memo(
({ multiple = false, onChange }: ImageUploadProps) => { ({ multiple = false, onChange }: ImageUploadProps) => {
const [isLoading, setIsLoading] = useState(false)
const [mediaOption, setMediaOption] = useState<MediaOption>( const [mediaOption, setMediaOption] = useState<MediaOption>(
MEDIA_OPTIONS[0] MEDIA_OPTIONS[0]
) )
@ -28,6 +31,7 @@ export const ImageUpload = React.memo(
async (acceptedFiles: File[]) => { async (acceptedFiles: File[]) => {
if (acceptedFiles.length) { if (acceptedFiles.length) {
try { try {
setIsLoading(true)
const imageController = new ImageController(mediaOption) const imageController = new ImageController(mediaOption)
const urls: string[] = [] const urls: string[] = []
for (let i = 0; i < acceptedFiles.length; i++) { for (let i = 0; i < acceptedFiles.length; i++) {
@ -37,6 +41,8 @@ export const ImageUpload = React.memo(
onChange(urls) onChange(urls)
} catch (error) { } catch (error) {
errorFeedback(error) errorFeedback(error)
} finally {
setIsLoading(false)
} }
} }
}, },
@ -79,7 +85,6 @@ export const ImageUpload = React.memo(
/> />
<div className='uploadBoxMainInside' {...getRootProps()} tabIndex={-1}> <div className='uploadBoxMainInside' {...getRootProps()} tabIndex={-1}>
<input id='featuredImageUrl-upload' {...getInputProps()} /> <input id='featuredImageUrl-upload' {...getInputProps()} />
<span>{dropzoneLabel}</span> <span>{dropzoneLabel}</span>
<div <div
className='FiltersMainElement' className='FiltersMainElement'
@ -109,6 +114,11 @@ export const ImageUpload = React.memo(
</div> </div>
</div> </div>
</div> </div>
{isLoading && (
<div className={styles.spinner}>
<Spinner />
</div>
)}
</div> </div>
</div> </div>
) )

View File

@ -26,7 +26,7 @@ import {
export const modRouteLoader = export const modRouteLoader =
(ndkContext: NDKContextType) => (ndkContext: NDKContextType) =>
async ({ params }: LoaderFunctionArgs) => { async ({ params, request }: LoaderFunctionArgs) => {
const { naddr } = params const { naddr } = params
if (!naddr) { if (!naddr) {
log(true, LogType.Error, 'Required naddr.') log(true, LogType.Error, 'Required naddr.')
@ -51,6 +51,14 @@ export const modRouteLoader =
const loggedInUserPubkey = const loggedInUserPubkey =
(userState?.user?.pubkey as string | undefined) || getFallbackPubkey() (userState?.user?.pubkey as string | undefined) || getFallbackPubkey()
// Check if editing and the user is the original author
// Redirect if NOT
const url = new URL(request.url)
const isEditMode = url.pathname.includes('edit-mod')
if (isEditMode && loggedInUserPubkey !== pubkey) {
return redirect(appRoutes.mods)
}
try { try {
// Set up the filters // Set up the filters
// Main mod content // Main mod content