@@ -26,6 +26,53 @@ import * as shell from "@tauri-apps/plugin-shell";
2626
2727export const Developer = ( ) => {
2828 const platformInfo = usePlatformInfo ( ) ;
29+ const DEV_TOKEN_BACKUP_KEY = "overlayed:dev:token-backup" ;
30+ const DEV_TOKEN_EXPIRY_BACKUP_KEY = "overlayed:dev:token-expiry-backup" ;
31+ const DEV_USER_DATA_BACKUP_KEY = "overlayed:dev:user-data-backup" ;
32+
33+ const simulateTokenExpiryForTesting = async ( ) => {
34+ const currentToken = localStorage . getItem ( "discord_access_token" ) ;
35+ const currentTokenExpiry = localStorage . getItem ( "discord_access_token_expiry" ) ;
36+ const currentUserData = localStorage . getItem ( "user_data" ) ;
37+
38+ if ( currentToken ) {
39+ localStorage . setItem ( DEV_TOKEN_BACKUP_KEY , currentToken ) ;
40+ }
41+ if ( currentTokenExpiry ) {
42+ localStorage . setItem ( DEV_TOKEN_EXPIRY_BACKUP_KEY , currentTokenExpiry ) ;
43+ }
44+ if ( currentUserData ) {
45+ localStorage . setItem ( DEV_USER_DATA_BACKUP_KEY , currentUserData ) ;
46+ }
47+
48+ // Clear auth keys so the app immediately routes back to the re-auth screen.
49+ localStorage . removeItem ( "discord_access_token" ) ;
50+ localStorage . removeItem ( "discord_access_token_expiry" ) ;
51+ localStorage . removeItem ( "user_data" ) ;
52+
53+ // Bring focus back to the main window where the auth screen is shown.
54+ await invoke ( "close_settings" ) ;
55+ } ;
56+
57+ const restoreTokenAfterTesting = ( ) => {
58+ const tokenBackup = localStorage . getItem ( DEV_TOKEN_BACKUP_KEY ) ;
59+ const tokenExpiryBackup = localStorage . getItem ( DEV_TOKEN_EXPIRY_BACKUP_KEY ) ;
60+ const userDataBackup = localStorage . getItem ( DEV_USER_DATA_BACKUP_KEY ) ;
61+
62+ if ( tokenBackup ) {
63+ localStorage . setItem ( "discord_access_token" , tokenBackup ) ;
64+ localStorage . removeItem ( DEV_TOKEN_BACKUP_KEY ) ;
65+ }
66+ if ( tokenExpiryBackup ) {
67+ localStorage . setItem ( "discord_access_token_expiry" , tokenExpiryBackup ) ;
68+ localStorage . removeItem ( DEV_TOKEN_EXPIRY_BACKUP_KEY ) ;
69+ }
70+ if ( userDataBackup ) {
71+ localStorage . setItem ( "user_data" , userDataBackup ) ;
72+ localStorage . removeItem ( DEV_USER_DATA_BACKUP_KEY ) ;
73+ }
74+ } ;
75+
2976 return (
3077 < >
3178 < div className = "flex flex-col gap-2" >
@@ -35,18 +82,10 @@ export const Developer = () => {
3582 variant = "outline"
3683 onClick = { async ( ) => {
3784 await invoke ( "open_devtools" ) ;
38- } }
39- >
40- Open Devtools
41- </ Button >
42- < Button
43- size = "sm"
44- variant = "outline"
45- onClick = { async ( ) => {
4685 await invoke ( "open_overlay_devtools" ) ;
4786 } }
4887 >
49- Open Overlay Devtools
88+ Open Devtools
5089 </ Button >
5190 < Button
5291 size = "sm"
@@ -57,7 +96,9 @@ export const Developer = () => {
5796 >
5897 Open Config Dir
5998 </ Button >
60- { import . meta. env . DEV && (
99+ </ div >
100+ { import . meta. env . DEV && (
101+ < div className = "flex gap-4 pb-2" >
61102 < Button
62103 size = "sm"
63104 variant = "outline"
@@ -67,8 +108,29 @@ export const Developer = () => {
67108 >
68109 Reset FTUE tip
69110 </ Button >
70- ) }
71- </ div >
111+ < Button
112+ size = "sm"
113+ variant = "outline"
114+ onClick = { ( ) => {
115+ void simulateTokenExpiryForTesting ( ) ;
116+ } }
117+ >
118+ Expire Auth
119+ </ Button >
120+ < Button size = "sm" variant = "outline" onClick = { restoreTokenAfterTesting } >
121+ Restore Auth
122+ </ Button >
123+ < Button
124+ size = "sm"
125+ variant = "outline"
126+ onClick = { async ( ) => {
127+ await invoke ( "simulate_error_screen" ) ;
128+ } }
129+ >
130+ Simulate Error Screen
131+ </ Button >
132+ </ div >
133+ ) }
72134 </ div >
73135 </ >
74136 ) ;
0 commit comments