refactor: hoist finally blocks out of the way of React Compiler
React Compiler cannot lower a `try` with a `finalizer` clause, so it silently skipped optimizing every component and hook containing one — 13 sites, confirmed by running the compiler over `src/`. none of the guarded bodies return or rethrow, so running the cleanup after the `try`/`catch` is equivalent. three of the sites were empty `finally {}` leftovers and are just gone.
87 unmodified lines8889909192939293949596979899100121 unmodified linesExpand all87 unmodified lines setPendingDid(account.did); await switchAccount(account); } catch (e) { console.error('sign in dialog: resume account failed', e); await login({ identifier: account.did }); } finally { setPendingDid(null); await login({ identifier: account.did }); return; } setPendingDid(null); }, [close, currentAccount?.did, pendingDid], );
121 unmodified linesExpand all118 unmodified linesExpand all11912012112212312412312412512612712831 unmodified lines118 unmodified linesExpand all } catch { Toast.show(m['screens.settings.interests.saveError'](), { type: 'error', }); } finally { setIsSaving(false); } setIsSaving(false); }, 1500, { onUnmount: 'flush' }, );31 unmodified lines23 unmodified lines2425262728292829303132332 unmodified lines23 unmodified lines signinDialogHandle.openWithPayload({ requestedAccount: account }); Toast.show(m['lib.error.signInAs']({ handle: account.handle }), { type: 'warning', }); } finally { setPendingDid(null); } setPendingDid(null); }, [pendingDid], );
2 unmodified lines290 unmodified linesExpand all2912922932942952952962972986 unmodified lines3053063073083103093103113123 unmodified lines316317318319322320321322323265 unmodified linesExpand all290 unmodified linesExpand all Toast.show(m['common.error.issueWithDetail']({ error: String(err) }), { type: 'error', }); } } finally { } };
const onMuteAuthor = async () => {6 unmodified lines Toast.show(m['common.error.issueWithDetail']({ error: String(err) }), { type: 'error', }); } } finally { } } else { try { await queueMute();3 unmodified lines Toast.show(m['common.error.issueWithDetail']({ error: String(err) }), { type: 'error', }); } } finally { } } };
265 unmodified linesExpand all315 unmodified linesExpand all316317318319320321320321322323324325147 unmodified linesExpand all315 unmodified linesExpand all setIsFetchingHandle(true); handle = await fetchHandle(handle); } catch { handle = undefined; } finally { setIsFetchingHandle(false); } setIsFetchingHandle(false); }
if (!handle || handle === currentAccount?.handle || isInvalidHandle(handle)) { return undefined;147 unmodified linesExpand all165 unmodified linesExpand all166167168169170171170171172173174175307 unmodified linesExpand all165 unmodified linesExpand all console.error('Failed to save post interaction settings', e); Toast.show(m['common.error.issueConnection'](), { type: 'error', }); } finally { setIsSaving(false); } setIsSaving(false); }, [ handle, props.postUri, props.rootPostUri,307 unmodified linesExpand all178 unmodified linesExpand all179180181182183184183184185186187188300 unmodified linesExpand all178 unmodified linesExpand all close(); } catch (e) { console.error('Failed to submit report', e); dispatch({ type: 'setError', error: reportErrorMessage(e) ?? m['common.error.generic']() }); } finally { setIsPending(false); } setIsPending(false); };
const title = copy.title; let onBack: (() => void) | undefined;300 unmodified linesExpand all795 unmodified linesExpand all79679779879980080180080180280380480575 unmodified lines795 unmodified linesExpand all ); router.navigate({ to: { name: 'MessagesConversation', conversation: data.convo.id } }); } catch (e) { console.error('Failed to get conversation', e); } finally { setIsLoading(false); } setIsLoading(false); };
if ( profile.associated?.chat?.allowIncoming === 'none' ||75 unmodified lines84 unmodified lines85868788899089909192939481 unmodified lines84 unmodified lines Toast.show(m['screens.list.savedFeeds.removedToast']()); } catch (e) { console.error('Failed to remove list from saved feeds', e); Toast.show(m['common.error.issueConnection']()); } finally { setIsProcessing(false); } setIsProcessing(false); };
return ( <div className={styles.container}>81 unmodified lines45 unmodified lines4647484950515051525354558 unmodified lines64656667697068697071727346 unmodified lines45 unmodified lines Toast.show(m['screens.settings.export.savedToast']()); } catch (e) { console.error('Error occurred while downloading CAR file', e); Toast.show(m['screens.settings.export.saveError'](), { type: 'error' }); } finally { setLoading(false); } setLoading(false); };
const downloadChatData = async () => { if (!chat) {8 unmodified lines Toast.show(m['screens.settings.export.savedToast']()); } catch (e) { console.error('Error occurred while downloading chat data', e); Toast.show(m['screens.settings.export.saveError'](), { type: 'error' }); } finally { setLoading(false); } setLoading(false); };
return ( <div className={styles.content}>46 unmodified lines