Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions ts/components/dialog/DeleteAccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { updateDeleteAccountModal } from '../../state/ducks/modalDialog';
import { SessionButton, SessionButtonColor, SessionButtonType } from '../basic/SessionButton';
import { SessionSpinner } from '../loading';

import {
deleteEverythingAndNetworkData,
sendConfigMessageAndDeleteEverything,
} from '../../util/accountManager';
import { deleteEverythingAndNetworkData, deleteAccountLocally } from '../../util/accountManager';
import { SessionRadioGroup } from '../basic/SessionRadioGroup';
import { tr } from '../../localization/localeTools';
import {
Expand Down Expand Up @@ -92,7 +89,7 @@ export const DeleteAccountModal = () => {
try {
window.log.warn('Deleting everything on device but keeping network data');

await sendConfigMessageAndDeleteEverything();
await deleteAccountLocally();
} catch (e) {
window.log.warn(e);
} finally {
Expand Down
3 changes: 2 additions & 1 deletion ts/components/dialog/EditProfilePictureModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const StyledAvatarContainer = styled.div`

const StyledCTADescription = styled.span<{ reverseDirection: boolean }>`
text-align: center;
cursor: pointer;
font-size: var(--font-size-lg);
color: var(--text-secondary-color);
line-height: normal;
Expand Down Expand Up @@ -276,7 +277,7 @@ export const EditProfilePictureModal = ({ conversationId }: EditProfilePictureMo
}
>
{isMe && proBadgeCb.cb ? (
<StyledCTADescription reverseDirection={userHasPro}>
<StyledCTADescription reverseDirection={userHasPro} onClick={proBadgeCb.cb}>
{tr(
userHasPro
? 'proAnimatedDisplayPictureModalDescription'
Expand Down
2 changes: 1 addition & 1 deletion ts/components/leftpane/ActionsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const triggerSyncIfNeeded = async () => {

const triggerAvatarReUploadIfNeeded = async () => {
const lastAvatarUploadExpiryMs =
(await Data.getItemById(SettingsKey.ntsAvatarExpiryMs))?.value || 0;
(await Data.getItemById(SettingsKey.ntsAvatarExpiryMs))?.value || Number.MAX_SAFE_INTEGER;

if (NetworkTime.now() > lastAvatarUploadExpiryMs) {
window.log.info('Reuploading avatar...');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function reuploadCurrentAvatarUs() {
const profileKey = ourConvoProfileKey ? fromHexToArray(ourConvoProfileKey) : null;
if (!profileKey || isEmpty(profileKey)) {
window.log.info('reuploadCurrentAvatarUs: our profileKey empty');

return null;
}
// Note: we do want to grab the current non-static avatar path here
Expand Down
16 changes: 3 additions & 13 deletions ts/util/accountManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ import { getSwarmPollingInstance } from '../session/apis/snode_api';
import { mnDecode, mnEncode } from '../session/crypto/mnemonic';
import { getOurPubKeyStrFromCache } from '../session/utils/User';
import { LibSessionUtil } from '../session/utils/libsession/libsession_utils';
import { forceSyncConfigurationNowIfNeeded } from '../session/utils/sync/syncUtils';
import { updateConfirmModal, updateDeleteAccountModal } from '../state/ducks/modalDialog';
import { userActions } from '../state/ducks/user';
import { Registration } from './registration';
import { Storage, saveRecoveryPhrase, setLocalPubKey, setSignInByLinking } from './storage';
import { PromiseUtils } from '../session/utils';
import { SnodeAPI } from '../session/apis/snode_api/SNodeAPI';
import { ReduxOnionSelectors } from '../state/selectors/onions';
import { tr } from '../localization/localeTools';

/**
Expand Down Expand Up @@ -269,18 +267,10 @@ export const deleteDbLocally = async () => {
window.localStorage.setItem('restart-reason', 'delete-account');
};

export async function sendConfigMessageAndDeleteEverything() {
export async function deleteAccountLocally() {
try {
// DELETE LOCAL DATA ONLY, NOTHING ON NETWORK
window?.log?.info('DeleteAccount => Sending a last SyncConfiguration');
if (ReduxOnionSelectors.isOnlineOutsideRedux()) {
// be sure to wait for the message being effectively sent. Otherwise we won't be able to encrypt it for our devices !
await forceSyncConfigurationNowIfNeeded(true);
window?.log?.info('Last configuration message sent!');
} else {
window?.log?.warn('sendConfigMessageAndDeleteEverything: we are offline, just deleting');
}

// Note: no point uploading a last config message as
// the user configs are being pushed after every changes made to them.
await deleteDbLocally();
} catch (error) {
// if an error happened, it's not related to the delete everything on network logic as this is handled above.
Expand Down