@@ -13,29 +13,19 @@ import {
1313 useUpdateProfileMutation ,
1414} from "@/features/profile/hooks" ;
1515import { NsecMaskedDisplay } from "@/features/onboarding/ui/NsecMaskedDisplay" ;
16- import { getNsec , signOut } from "@/shared/api/tauriIdentity" ;
17- import {
18- AlertDialog ,
19- AlertDialogAction ,
20- AlertDialogCancel ,
21- AlertDialogContent ,
22- AlertDialogDescription ,
23- AlertDialogFooter ,
24- AlertDialogHeader ,
25- AlertDialogTitle ,
26- } from "@/shared/ui/alert-dialog" ;
16+ import { getNsec } from "@/shared/api/tauriIdentity" ;
2717import { MaskedAvatarBadgeFrame } from "@/features/profile/ui/MaskedAvatarBadgeFrame" ;
2818import { ProfileAvatar } from "@/features/profile/ui/ProfileAvatar" ;
2919import {
3020 ProfileAvatarEditor ,
3121 parseEmojiAvatarDataUrl ,
3222} from "@/features/profile/ui/ProfileAvatarEditor" ;
3323import { cn } from "@/shared/lib/cn" ;
34- import { Button } from "@/shared/ui/button" ;
3524import { Input } from "@/shared/ui/input" ;
3625import { Spinner } from "@/shared/ui/spinner" ;
3726import { Textarea } from "@/shared/ui/textarea" ;
3827import { SettingsSectionHeader } from "./SettingsSectionHeader" ;
28+ import { SignOutSection } from "./SignOutSection" ;
3929import { writeTextToClipboard } from "@/shared/lib/clipboard" ;
4030
4131type ProfileSettingsCardProps = {
@@ -262,8 +252,6 @@ export function ProfileSettingsCard({
262252 const [ shouldRenderAvatarEditor , setShouldRenderAvatarEditor ] =
263253 React . useState ( false ) ;
264254 const [ avatarSquishKey , setAvatarSquishKey ] = React . useState ( 0 ) ;
265- const [ isSignOutOpen , setIsSignOutOpen ] = React . useState ( false ) ;
266- const [ isSignOutPending , setIsSignOutPending ] = React . useState ( false ) ;
267255 const displayNameInputRef = React . useRef < HTMLInputElement > ( null ) ;
268256 const aboutTextareaRef = React . useRef < HTMLTextAreaElement > ( null ) ;
269257 const sectionRef = React . useRef < HTMLElement > ( null ) ;
@@ -956,88 +944,7 @@ export function ProfileSettingsCard({
956944 </ div >
957945 </ div >
958946
959- < div
960- className = "mt-8 border-t border-border/60 pb-6 pt-5"
961- data-testid = "settings-signout"
962- >
963- < div className = "flex items-center justify-between gap-4 px-1" >
964- < div className = "min-w-0 space-y-1" >
965- < h2 className = "text-lg font-semibold tracking-tight" > Sign out</ h2 >
966- < p className = "text-sm text-muted-foreground" >
967- Removes your identity key and all local app data from this device.
968- Back up your private key (nsec) first — this cannot be undone.
969- </ p >
970- </ div >
971- < Button
972- className = "shrink-0"
973- data-testid = "signout-open-dialog"
974- disabled = { isSignOutPending }
975- onClick = { ( ) => setIsSignOutOpen ( true ) }
976- type = "button"
977- variant = "destructive"
978- >
979- { isSignOutPending ? (
980- < Spinner aria-label = "Signing out" className = "h-4 w-4 border-2" />
981- ) : null }
982- { isSignOutPending ? "Signing out…" : "Sign Out" }
983- </ Button >
984- </ div >
985- < AlertDialog
986- onOpenChange = { ( open ) => {
987- if ( ! open && ! isSignOutPending ) setIsSignOutOpen ( false ) ;
988- } }
989- open = { isSignOutOpen }
990- >
991- < AlertDialogContent >
992- < AlertDialogHeader >
993- < AlertDialogTitle > Sign out and wipe all data?</ AlertDialogTitle >
994- < AlertDialogDescription >
995- This will delete your identity key, all agent settings, and
996- cached data from this device, then relaunch Buzz into first-run
997- setup. Make sure you have your private key (nsec) backed up
998- before continuing — this cannot be undone.
999- </ AlertDialogDescription >
1000- </ AlertDialogHeader >
1001- < AlertDialogFooter >
1002- < AlertDialogCancel disabled = { isSignOutPending } >
1003- Cancel
1004- </ AlertDialogCancel >
1005- < AlertDialogAction
1006- className = "bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90"
1007- data-testid = "signout-confirm"
1008- disabled = { isSignOutPending }
1009- onClick = { ( ) => {
1010- setIsSignOutPending ( true ) ;
1011- // Keep the pending state if signOut() resolves before restart.
1012- signOut ( )
1013- . then ( ( ) => {
1014- // Clear web storage for this origin on the success path
1015- // only. This covers dev builds where the Rust webview wipe
1016- // targets the .app-bundle WebKit dir (missing in `tauri
1017- // dev`), preventing stale community config from vouching
1018- // for the fresh key on next boot. In production the Rust
1019- // wipe already handles this; the clear here is redundant
1020- // but harmless. The restart may race this clear — that is
1021- // acceptable; Fix A (pubkey-scoped heuristic) is the
1022- // correctness gate.
1023- window . localStorage . clear ( ) ;
1024- window . sessionStorage . clear ( ) ;
1025- } )
1026- . catch ( ( err : unknown ) => {
1027- setIsSignOutPending ( false ) ;
1028- setIsSignOutOpen ( false ) ;
1029- toast . error (
1030- err instanceof Error ? err . message : "Sign out failed." ,
1031- ) ;
1032- } ) ;
1033- } }
1034- >
1035- { isSignOutPending ? "Signing out…" : "Delete My Data" }
1036- </ AlertDialogAction >
1037- </ AlertDialogFooter >
1038- </ AlertDialogContent >
1039- </ AlertDialog >
1040- </ div >
947+ < SignOutSection />
1041948 </ section >
1042949 ) ;
1043950}
0 commit comments