@ -11,7 +11,7 @@ import { SessionSpinner } from '../session/SessionSpinner';
import { SessionWrapperModal } from '../session/SessionWrapperModal' ;
import { SessionWrapperModal } from '../session/SessionWrapperModal' ;
const deleteDbLocally = async ( ) = > {
const deleteDbLocally = async ( ) = > {
window ? . log ? . info ( ' configuration message sent successfully. Deleting everything') ;
window ? . log ? . info ( ' last message sent successfully. Deleting everything') ;
window . persistStore ? . purge ( ) ;
window . persistStore ? . purge ( ) ;
await window . Signal . Logs . deleteAll ( ) ;
await window . Signal . Logs . deleteAll ( ) ;
await window . Signal . Data . removeAll ( ) ;
await window . Signal . Data . removeAll ( ) ;
@ -128,15 +128,13 @@ async function deleteEverythingAndNetworkData() {
export const DeleteAccountModal = ( ) = > {
export const DeleteAccountModal = ( ) = > {
const [ isLoading , setIsLoading ] = useState ( false ) ;
const [ isLoading , setIsLoading ] = useState ( false ) ;
const [ deleteDeviceOnly , setDeleteDeviceOnly ] = useState ( false ) ;
const [ deleteEverythingWithNetwork , setDeleteEverythingWithNetwork ] = useState ( false ) ;
const dispatch = useDispatch ( ) ;
const dispatch = useDispatch ( ) ;
const onDeleteEverythingLocallyOnly = ( ) = > {
const onDeleteEverythingLocallyOnly = async ( ) = > {
dispatch (
if ( ! isLoading ) {
updateConfirmModal ( {
message : window.i18n ( 'areYouSureDeleteDeviceOnly' ) ,
okText : window.i18n ( 'iAmSure' ) ,
okTheme : SessionButtonColor.Danger ,
onClickOk : async ( ) = > {
setIsLoading ( true ) ;
setIsLoading ( true ) ;
try {
try {
window . log . warn ( 'Deleting everything on device but keeping network data' ) ;
window . log . warn ( 'Deleting everything on device but keeping network data' ) ;
@ -147,20 +145,10 @@ export const DeleteAccountModal = () => {
} finally {
} finally {
setIsLoading ( false ) ;
setIsLoading ( false ) ;
}
}
} ,
}
onClickClose : ( ) = > {
window . inboxStore ? . dispatch ( updateConfirmModal ( null ) ) ;
} ,
} )
) ;
} ;
} ;
const onDeleteEverythingAndNetworkData = ( ) = > {
const onDeleteEverythingAndNetworkData = async ( ) = > {
dispatch (
if ( ! isLoading ) {
updateConfirmModal ( {
message : window.i18n ( 'areYouSureDeleteEntireAccount' ) ,
okText : window.i18n ( 'iAmSure' ) ,
okTheme : SessionButtonColor.Danger ,
onClickOk : async ( ) = > {
setIsLoading ( true ) ;
setIsLoading ( true ) ;
try {
try {
window . log . warn ( 'Deleting everything including network data' ) ;
window . log . warn ( 'Deleting everything including network data' ) ;
@ -170,19 +158,14 @@ export const DeleteAccountModal = () => {
} finally {
} finally {
setIsLoading ( false ) ;
setIsLoading ( false ) ;
}
}
} ,
}
onClickClose : ( ) = > {
window . inboxStore ? . dispatch ( updateConfirmModal ( null ) ) ;
} ,
} )
) ;
} ;
} ;
/ * *
/ * *
* Performs specified on close action then removes the modal .
* Performs specified on close action then removes the modal .
* /
* /
const onClickCancelHandler = useCallback ( ( ) = > {
const onClickCancelHandler = useCallback ( ( ) = > {
window . inboxStore ? . dispatch ( updateDeleteAccountModal ( null ) ) ;
dispatch ( updateDeleteAccountModal ( null ) ) ;
} , [ ] ) ;
} , [ ] ) ;
return (
return (
@ -209,17 +192,65 @@ export const DeleteAccountModal = () => {
< SessionButton
< SessionButton
text = { window . i18n ( 'entireAccount' ) }
text = { window . i18n ( 'entireAccount' ) }
buttonColor = { SessionButtonColor . Danger }
buttonColor = { SessionButtonColor . Danger }
onClick = { onDeleteEverythingAndNetworkData }
onClick = { ( ) = > {
disabled = { isLoading }
setDeleteEverythingWithNetwork ( true ) ;
} }
disabled = { deleteEverythingWithNetwork || deleteDeviceOnly }
/ >
/ >
< SessionButton
< SessionButton
text = { window . i18n ( 'deviceOnly' ) }
text = { window . i18n ( 'deviceOnly' ) }
buttonColor = { SessionButtonColor . Primary }
buttonColor = { SessionButtonColor . Primary }
onClick = { onDeleteEverythingLocallyOnly }
onClick = { ( ) = > {
setDeleteDeviceOnly ( true ) ;
} }
disabled = { deleteEverythingWithNetwork || deleteDeviceOnly }
/ >
< / div >
< SpacerLG / >
{ deleteEverythingWithNetwork && (
< SessionHtmlRenderer
tag = "span"
className = "session-confirm-main-message"
html = { window . i18n ( 'areYouSureDeleteEntireAccount' ) }
/ >
) }
{ deleteDeviceOnly && (
< SessionHtmlRenderer
tag = "span"
className = "session-confirm-main-message"
html = { window . i18n ( 'areYouSureDeleteDeviceOnly' ) }
/ >
) }
< SpacerLG / >
{ ( deleteDeviceOnly || deleteEverythingWithNetwork ) && (
< div className = "session-modal__button-group" >
< SessionButton
text = { window . i18n ( 'iAmSure' ) }
buttonColor = { SessionButtonColor . Danger }
onClick = { ( ) = > {
if ( deleteDeviceOnly ) {
void onDeleteEverythingLocallyOnly ( ) ;
} else if ( deleteEverythingWithNetwork ) {
void onDeleteEverythingAndNetworkData ( ) ;
}
} }
disabled = { isLoading }
/ >
< SessionButton
text = { window . i18n ( 'cancel' ) }
buttonColor = { SessionButtonColor . Primary }
onClick = { ( ) = > {
dispatch ( updateDeleteAccountModal ( null ) ) ;
} }
disabled = { isLoading }
disabled = { isLoading }
/ >
/ >
< / div >
< / div >
) }
< SessionSpinner loading = { isLoading } / >
< SessionSpinner loading = { isLoading } / >
< / div >
< / div >