Skip to content

Commit

Permalink
fix logout bug
Browse files Browse the repository at this point in the history
  • Loading branch information
trazyn committed Sep 14, 2017
1 parent 352cee2 commit cb8a554
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class App extends Component {
ipcRenderer.on('os-resume', async() => {
var session = stores.session;

console.log('os-resume');
console.log('os-resume' + new Date());
setTimeout(() => {
session.checkTimeout(true);
}, 3000);
Expand Down
2 changes: 0 additions & 2 deletions src/js/components/Avatar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import React, { Component, PropTypes } from 'react';
import clazz from 'classname';

import blacklist from 'utils/blacklist';
import './style.global.css';

export default class Avatar extends Component {
Expand All @@ -28,7 +27,6 @@ export default class Avatar extends Component {

return (
<img
{...blacklist(this.props, 'fallback', 'className', 'onLoad', 'onError')}
className={clazz('Avatar', 'fade fadein', this.props.className)}
onLoad={e => this.handleLoad(e)}
onError={e => this.handleError(e)} />
Expand Down
23 changes: 15 additions & 8 deletions src/js/stores/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,19 @@ class Session {
}

// A callback for cancel the sync request
syncTimeout = window.Function;
cancelCheck = window.Function;

checkTimeout(weakup) {
// Kill the zombie request or duplicate request
self.syncTimeout();
self.cancelCheck();
clearTimeout(self.checkTimeout.timer);

if (helper.isSuspend() || weakup) {
return;
}

self.checkTimeout.timer = setTimeout(() => {
self.syncTimeout();
self.cancelCheck();
}, 30 * 1000);
}

Expand All @@ -239,7 +239,7 @@ class Session {
var response = await axios.get(`${host}cgi-bin/mmwebwx-bin/synccheck`, {
cancelToken: new CancelToken(exe => {
// An executor function receives a cancel function as a parameter
this.syncTimeout = exe;
this.cancelCheck = exe;
}),
params: {
r: +new Date(),
Expand Down Expand Up @@ -309,10 +309,17 @@ class Session {
@action async logout() {
var auth = self.auth;

await axios.post(`/cgi-bin/mmwebwx-bin/webwxlogout?skey=${auth.skey}&redirect=0&type=1`, {
sid: auth.sid,
uin: auth.uid,
});
try {
await axios.post(`/cgi-bin/mmwebwx-bin/webwxlogout?skey=${auth.skey}&redirect=0&type=1`, {
sid: auth.sid,
uin: auth.uid,
});
} finally {
self.exit();
}
}

async exit() {
await storage.remove('auth');
window.location.reload();
}
Expand Down

0 comments on commit cb8a554

Please sign in to comment.