mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
WIP
This commit is contained in:
parent
99cc5b448a
commit
e466062f15
|
@ -24,6 +24,18 @@
|
|||
return textsecure.utils.unencodeNumber(numberId)[0];
|
||||
},
|
||||
|
||||
isRestoringFromSeed() {
|
||||
const isRestoring = textsecure.storage.get('is_restoring_from_seed');
|
||||
if (isRestoring === undefined) {
|
||||
return false;
|
||||
}
|
||||
return isRestoring;
|
||||
},
|
||||
|
||||
setRestoringFromSeed(isRestoringFromSeed) {
|
||||
textsecure.storage.put('is_restoring_from_seed', isRestoringFromSeed);
|
||||
},
|
||||
|
||||
getDeviceId() {
|
||||
const numberId = textsecure.storage.get('number_id');
|
||||
if (numberId === undefined) {
|
||||
|
|
|
@ -517,9 +517,12 @@ window.deleteAccount = async reason => {
|
|||
try {
|
||||
window.log.info('DeleteAccount => Sending a last SyncConfiguration');
|
||||
// be sure to wait for the message being effectively sent. Otherwise we won't be able to encrypt it for our devices !
|
||||
window.log.info('Sending one last configuration message.')
|
||||
await window.libsession.Utils.SyncUtils.forceSyncConfigurationNowIfNeeded(
|
||||
true
|
||||
);
|
||||
window.log.info('Last configuration message sent!')
|
||||
|
||||
await syncedMessageSent();
|
||||
} catch (error) {
|
||||
window.log.error(
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
import { trigger } from '../../shims/events';
|
||||
import { SessionHtmlRenderer } from './SessionHTMLRenderer';
|
||||
import { SessionIdEditable } from './SessionIdEditable';
|
||||
import { StringUtils, ToastUtils } from '../../session/utils';
|
||||
import { StringUtils, ToastUtils, UserUtils } from '../../session/utils';
|
||||
import { lightTheme } from '../../state/ducks/SessionTheme';
|
||||
import { ConversationController } from '../../session/conversations';
|
||||
import { PasswordUtil } from '../../util';
|
||||
|
@ -702,12 +702,24 @@ export class RegistrationTabs extends React.Component<any, State> {
|
|||
await this.resetRegistration();
|
||||
|
||||
await window.setPassword(password);
|
||||
const isRestoringFromSeed = signInMode === SignInMode.UsingRecoveryPhrase;
|
||||
UserUtils.setRestoringFromSeed(isRestoringFromSeed);
|
||||
|
||||
await this.accountManager.registerSingleDevice(
|
||||
seedToUse,
|
||||
language,
|
||||
trimName
|
||||
);
|
||||
trigger('openInbox');
|
||||
// if we are just creating a new account, no need to wait for a configuration message
|
||||
if (!isRestoringFromSeed) {
|
||||
trigger('openInbox');
|
||||
} else {
|
||||
// We have to pull for all messages of the user of this menmonic
|
||||
// We are looking for the most recent ConfigurationMessage he sent to himself.
|
||||
// When we find it, we can just get the displayName, avatar and groups saved in it.
|
||||
// If we do not find one, we will need to ask for a display name.
|
||||
window.log.warn('isRestoringFromSeed');
|
||||
}
|
||||
} catch (e) {
|
||||
ToastUtils.pushToastError(
|
||||
'registrationError',
|
||||
|
|
|
@ -390,7 +390,7 @@ export async function innerHandleContentMessage(
|
|||
'private'
|
||||
);
|
||||
|
||||
if (content.dataMessage) {
|
||||
if (content.dataMessage && !UserUtils.isRestoringFromSeed()) {
|
||||
if (
|
||||
content.dataMessage.profileKey &&
|
||||
content.dataMessage.profileKey.length === 0
|
||||
|
@ -401,15 +401,16 @@ export async function innerHandleContentMessage(
|
|||
return;
|
||||
}
|
||||
|
||||
if (content.receiptMessage) {
|
||||
if (content.receiptMessage && !UserUtils.isRestoringFromSeed()) {
|
||||
await handleReceiptMessage(envelope, content.receiptMessage);
|
||||
return;
|
||||
}
|
||||
if (content.typingMessage) {
|
||||
if (content.typingMessage && !UserUtils.isRestoringFromSeed()) {
|
||||
await handleTypingMessage(envelope, content.typingMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
// Be sure to check for the UserUtils.isRestoringFromSeed() if you add another if here
|
||||
if (content.configurationMessage) {
|
||||
await handleConfigurationMessage(
|
||||
envelope,
|
||||
|
@ -417,6 +418,7 @@ export async function innerHandleContentMessage(
|
|||
);
|
||||
return;
|
||||
}
|
||||
// Be sure to check for the UserUtils.isRestoringFromSeed() if you add another if here
|
||||
} catch (e) {
|
||||
window.log.warn(e);
|
||||
}
|
||||
|
|
|
@ -69,3 +69,18 @@ export async function getUserED25519KeyPair(): Promise<HexKeyPair | undefined> {
|
|||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the public key of this current device as a STRING, or throws an error
|
||||
*/
|
||||
export function isRestoringFromSeed(): boolean {
|
||||
const ourNumber = window.textsecure.storage.user.isRestoringFromSeed();
|
||||
if (!ourNumber) {
|
||||
throw new Error('ourNumber is not set');
|
||||
}
|
||||
return ourNumber;
|
||||
}
|
||||
|
||||
export function setRestoringFromSeed(isRestoring: boolean) {
|
||||
window.textsecure.storage.user.setRestoringFromSeed(isRestoring);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ export const forceSyncConfigurationNowIfNeeded = async (
|
|||
async function waitForMessageSentEvent(message: RawMessage) {
|
||||
return new Promise(resolve => {
|
||||
if (message.identifier === configMessage.identifier) {
|
||||
// might have fail in fact
|
||||
debugger;
|
||||
resolve(true);
|
||||
}
|
||||
});
|
||||
|
@ -61,10 +63,9 @@ export const forceSyncConfigurationNowIfNeeded = async (
|
|||
configMessage,
|
||||
waitForMessageSentEvent as any
|
||||
);
|
||||
return Promise.resolve();
|
||||
return waitForMessageSentEvent;
|
||||
} else {
|
||||
await getMessageQueue().sendSyncMessage(configMessage);
|
||||
return waitForMessageSentEvent;
|
||||
}
|
||||
} catch (e) {
|
||||
window.log.warn(
|
||||
|
|
Loading…
Reference in a new issue