1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-07 21:47:02 +09:00

refactoring

This commit is contained in:
Andrew Simachev 2025-04-23 12:15:23 +02:00
parent 240386b585
commit d968ded518
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF
5 changed files with 24 additions and 26 deletions

View file

@ -104,9 +104,7 @@ class Iframe extends React.Component {
return;
};
U.Data.destroySubscriptions(() => {
C.WalletCloseSession(S.Auth.token, () => S.Auth.tokenSet(''));
});
U.Data.destroySubscriptions(() => U.Data.closeSession());
});
};

View file

@ -87,9 +87,7 @@ class Popup extends React.Component {
return;
};
U.Data.destroySubscriptions(() => {
C.WalletCloseSession(S.Auth.token, () => S.Auth.tokenSet(''));
});
U.Data.destroySubscriptions(() => U.Data.closeSession());
});
};

View file

@ -392,10 +392,7 @@ class App extends React.Component<object, State> {
};
e.preventDefault();
C.WalletCloseSession(S.Auth.token, () => {
S.Auth.tokenSet('');
window.close();
});
U.Data.closeSession(() => window.close());
return false;
});
} else {

View file

@ -486,8 +486,7 @@ class UtilData {
};
createSession (phrase: string, key: string, callBack?: (message: any) => void) {
const { token } = S.Auth;
const cb = () => {
this.closeSession(() => {
C.WalletCreateSession(phrase, key, (message: any) => {
if (!message.error.code) {
S.Auth.tokenSet(message.token);
@ -499,16 +498,26 @@ class UtilData {
callBack(message);
};
});
});
};
closeSession (callBack?: () => void) {
const { token } = S.Auth;
if (!token) {
if (callBack) {
callBack();
};
return;
};
if (token) {
C.WalletCloseSession(token, () => {
S.Auth.tokenSet('');
cb();
});
} else {
cb();
};
C.WalletCloseSession(token, () => {
S.Auth.tokenSet('');
if (callBack) {
callBack();
};
});
};
blockSetText (rootId: string, blockId: string, text: string, marks: I.Mark[], update: boolean, callBack?: (message: any) => void) {

View file

@ -179,15 +179,11 @@ class AuthStore {
};
logout (mainWindow: boolean, removeData: boolean) {
const cb = () => {
C.WalletCloseSession(this.token, () => this.tokenSet(''));
};
if (mainWindow) {
C.AccountStop(removeData, () => cb());
C.AccountStop(removeData, () => U.Data.closeSession());
Renderer.send('logout');
} else {
cb();
U.Data.closeSession();
};
analytics.profile('', '');