mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-07 21:47:02 +09:00
refactoring
This commit is contained in:
parent
240386b585
commit
d968ded518
5 changed files with 24 additions and 26 deletions
|
@ -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());
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -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());
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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('', '');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue