@@ -81,53 +81,64 @@ export default function UploadScreen() {
8181
8282 const handleUpload = useCallback ( async ( type : UploadType ) => {
8383 if ( isUploading ) return ;
84+
8485 setIsUploading ( true ) ;
8586
8687 try {
87- await requestNotificationsPermission ( ) ;
88+ // Request notifications permission first (but don't block on it)
89+ requestNotificationsPermission ( ) . catch ( console . warn ) ;
90+
8891 const options : ShareOptions = {
8992 expiry : tempExpiry . trim ( ) || undefined ,
9093 oneshot : tempIsOneShot || undefined ,
9194 } ;
9295
93- let resultUrl : string | undefined ;
96+ let resultUrl : string | null = null ;
9497
9598 switch ( type ) {
9699 case 'text' :
97100 if ( ! text . trim ( ) ) {
98101 Alert . alert ( 'Error' , 'Please enter some text to upload.' ) ;
99102 return ;
100103 }
101- resultUrl = await uploadText ( text . trim ( ) , settings . serverUrl , settings . authToken , options ) as string ;
104+ resultUrl = await uploadText ( text . trim ( ) , settings . serverUrl , settings . authToken , options ) ;
102105 setText ( '' ) ;
103106 break ;
104107 case 'file' :
105- resultUrl = await pickAndUploadFile ( settings . serverUrl , settings . authToken , options ) as string ;
108+ resultUrl = await pickAndUploadFile ( settings . serverUrl , settings . authToken , options ) ;
109+ // If user cancelled, resultUrl will be null - don't show error
106110 break ;
107111 case 'image' :
108- resultUrl = await pickAndUploadImage ( settings . serverUrl , settings . authToken , options ) as string ;
112+ resultUrl = await pickAndUploadImage ( settings . serverUrl , settings . authToken , options ) ;
113+ // If user cancelled, resultUrl will be null - don't show error
109114 break ;
110115 case 'url' :
111116 if ( ! url . trim ( ) ) {
112117 Alert . alert ( 'Error' , 'Please enter a URL to shorten.' ) ;
113118 return ;
114119 }
115- resultUrl = await shortenUrl ( url . trim ( ) , settings . serverUrl , settings . authToken , options ) as string ;
120+ resultUrl = await shortenUrl ( url . trim ( ) , settings . serverUrl , settings . authToken , options ) ;
116121 setUrl ( '' ) ;
117122 break ;
118123 case 'remote' :
119124 if ( ! url . trim ( ) ) {
120125 Alert . alert ( 'Error' , 'Please enter a remote URL to upload.' ) ;
121126 return ;
122127 }
123- resultUrl = await uploadFromRemoteUrl ( url . trim ( ) , settings . serverUrl , settings . authToken , options ) as string ;
128+ resultUrl = await uploadFromRemoteUrl ( url . trim ( ) , settings . serverUrl , settings . authToken , options ) ;
124129 setUrl ( '' ) ;
125130 break ;
126131 }
127132
133+ // resultUrl will be null if user cancelled file/image picker
134+ if ( resultUrl ) {
135+ console . log ( 'Upload successful:' , resultUrl ) ;
136+ }
137+
128138 } catch ( error ) {
129139 const message = error instanceof Error ? error . message : 'Unknown error' ;
130140 console . error ( 'Upload error:' , message ) ;
141+ Alert . alert ( 'Upload Error' , message ) ;
131142 } finally {
132143 setIsUploading ( false ) ;
133144 }
@@ -253,12 +264,24 @@ export default function UploadScreen() {
253264 editable = { ! isUploading }
254265 />
255266 < Pressable
256- style = { ( { pressed } ) => [ styles . button , { backgroundColor : primaryColor , opacity : isUploading ? 0.6 : pressed ? 0.8 : 1 } ] }
267+ style = { ( { pressed } ) => [
268+ styles . button ,
269+ {
270+ backgroundColor : primaryColor ,
271+ opacity : isUploading ? 0.6 : pressed ? 0.8 : 1
272+ }
273+ ] }
257274 onPress = { ( ) => handleUpload ( 'text' ) }
258275 disabled = { isUploading }
259276 >
260- < Ionicons name = "cloud-upload-outline" size = { 20 } color = "#FFFFFF" />
261- < ThemedText style = { styles . buttonText } > Upload Text</ ThemedText >
277+ < Ionicons
278+ name = { isUploading ? "hourglass-outline" : "cloud-upload-outline" }
279+ size = { 20 }
280+ color = "#FFFFFF"
281+ />
282+ < ThemedText style = { styles . buttonText } >
283+ { isUploading ? 'Uploading...' : 'Upload Text' }
284+ </ ThemedText >
262285 </ Pressable >
263286 </ ThemedView >
264287
@@ -267,20 +290,40 @@ export default function UploadScreen() {
267290 { renderSectionHeader ( 'Upload File' , 'document-attach-outline' ) }
268291 < ThemedView style = { styles . buttonRow } >
269292 < Pressable
270- style = { ( { pressed } ) => [ styles . button , styles . secondaryButton , { opacity : isUploading ? 0.6 : pressed ? 0.8 : 1 } ] }
293+ style = { ( { pressed } ) => [
294+ styles . button ,
295+ styles . secondaryButton ,
296+ { opacity : isUploading ? 0.6 : pressed ? 0.8 : 1 }
297+ ] }
271298 onPress = { ( ) => handleUpload ( 'file' ) }
272299 disabled = { isUploading }
273300 >
274- < Ionicons name = "document-outline" size = { 20 } color = { primaryColor } />
275- < ThemedText style = { [ styles . buttonText , styles . secondaryButtonText ] } > Choose File</ ThemedText >
301+ < Ionicons
302+ name = { isUploading ? "hourglass-outline" : "document-outline" }
303+ size = { 20 }
304+ color = { primaryColor }
305+ />
306+ < ThemedText style = { [ styles . buttonText , styles . secondaryButtonText ] } >
307+ { isUploading ? 'Loading...' : 'Choose File' }
308+ </ ThemedText >
276309 </ Pressable >
277310 < Pressable
278- style = { ( { pressed } ) => [ styles . button , styles . secondaryButton , { opacity : isUploading ? 0.6 : pressed ? 0.8 : 1 } ] }
311+ style = { ( { pressed } ) => [
312+ styles . button ,
313+ styles . secondaryButton ,
314+ { opacity : isUploading ? 0.6 : pressed ? 0.8 : 1 }
315+ ] }
279316 onPress = { ( ) => handleUpload ( 'image' ) }
280317 disabled = { isUploading }
281318 >
282- < Ionicons name = "image-outline" size = { 20 } color = { primaryColor } />
283- < ThemedText style = { [ styles . buttonText , styles . secondaryButtonText ] } > Choose Image</ ThemedText >
319+ < Ionicons
320+ name = { isUploading ? "hourglass-outline" : "image-outline" }
321+ size = { 20 }
322+ color = { primaryColor }
323+ />
324+ < ThemedText style = { [ styles . buttonText , styles . secondaryButtonText ] } >
325+ { isUploading ? 'Loading...' : 'Choose Image' }
326+ </ ThemedText >
284327 </ Pressable >
285328 </ ThemedView >
286329 </ ThemedView >
@@ -300,20 +343,42 @@ export default function UploadScreen() {
300343 />
301344 < ThemedView style = { styles . buttonRow } >
302345 < Pressable
303- style = { ( { pressed } ) => [ styles . button , styles . secondaryButton , { opacity : isUploading ? 0.6 : pressed ? 0.8 : 1 } ] }
346+ style = { ( { pressed } ) => [
347+ styles . button ,
348+ styles . secondaryButton ,
349+ { opacity : isUploading ? 0.6 : pressed ? 0.8 : 1 }
350+ ] }
304351 onPress = { ( ) => handleUpload ( 'url' ) }
305352 disabled = { isUploading }
306353 >
307- < Ionicons name = "cut-outline" size = { 20 } color = { primaryColor } />
308- < ThemedText style = { [ styles . buttonText , styles . secondaryButtonText ] } > Shorten</ ThemedText >
354+ < Ionicons
355+ name = { isUploading ? "hourglass-outline" : "cut-outline" }
356+ size = { 20 }
357+ color = { primaryColor }
358+ />
359+ < ThemedText style = { [ styles . buttonText , styles . secondaryButtonText ] } >
360+ { isUploading ? 'Processing...' : 'Shorten' }
361+ </ ThemedText >
309362 </ Pressable >
310363 < Pressable
311- style = { ( { pressed } ) => [ styles . button , { backgroundColor : primaryColor , opacity : isUploading ? 0.6 : pressed ? 0.8 : 1 } ] }
364+ style = { ( { pressed } ) => [
365+ styles . button ,
366+ {
367+ backgroundColor : primaryColor ,
368+ opacity : isUploading ? 0.6 : pressed ? 0.8 : 1
369+ }
370+ ] }
312371 onPress = { ( ) => handleUpload ( 'remote' ) }
313372 disabled = { isUploading }
314373 >
315- < Ionicons name = "cloud-download-outline" size = { 20 } color = "#FFFFFF" />
316- < ThemedText style = { styles . buttonText } > Upload</ ThemedText >
374+ < Ionicons
375+ name = { isUploading ? "hourglass-outline" : "cloud-download-outline" }
376+ size = { 20 }
377+ color = "#FFFFFF"
378+ />
379+ < ThemedText style = { styles . buttonText } >
380+ { isUploading ? 'Uploading...' : 'Upload' }
381+ </ ThemedText >
317382 </ Pressable >
318383 </ ThemedView >
319384 </ ThemedView >
0 commit comments