Skip to content

Commit 4595dd7

Browse files
authored
Merge pull request #2506 from uProxy/fix-logout
Fix issues with expectedLogout not getting set
2 parents eb01412 + 85277f6 commit 4595dd7

File tree

4 files changed

+10
-40
lines changed

4 files changed

+10
-40
lines changed

src/generic_ui/polymer/network-in-settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Polymer({
5858
}
5959

6060
confirmLogout.then(() => {
61-
ui.logout({
61+
this.$.state.background.logout({
6262
name: this.name,
6363
userId: this.networkInfo.userId
6464
});

src/generic_ui/polymer/state.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ class Background {
8787
}
8888

8989
public logout = (networkInfo: social.SocialNetworkInfo): Promise<void> => {
90+
var network = ui_context.model.getNetwork(networkInfo.name);
91+
if (!network) {
92+
console.warn('Network is not logged in');
93+
return Promise.resolve<void>();
94+
}
95+
96+
network.logoutExpected = true;
97+
9098
return this.doInBackground_('logout', networkInfo, true);
9199
}
92100

src/generic_ui/scripts/ui.spec.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -351,25 +351,4 @@ describe('UI.UserInterface', () => {
351351
expect(ui.gettingStatus).toEqual(null);
352352
});
353353
}); // Update giving and/or getting state in UI
354-
355-
describe('logout', () => {
356-
it('No networks', (done) => {
357-
ui.logout({ name: 'testNetwork', userId: 'fakeUser' }).then(() => {
358-
expect(mockCore.logout).not.toHaveBeenCalled();
359-
done();
360-
});
361-
});
362-
363-
it('Single network', (done) => {
364-
login();
365-
ui.logout({ name: 'testNetwork', userId: 'fakeUser' }).then(() => {;
366-
expect(mockCore.logout).toHaveBeenCalled();
367-
logout(); //cleanup
368-
done();
369-
}).catch(() => {
370-
logout();
371-
expect('Error: rejected promise').toEqual(false);
372-
});
373-
});
374-
});
375354
}); // UI.UserInterface

src/generic_ui/scripts/ui.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,7 @@ export class UserInterface implements ui_constants.UiApi {
329329
* though
330330
*/
331331
switch(name) {
332-
case 'logout':
333-
this.logout(data.data.networkInfo);
334-
break;
332+
/* holding for more operations as needed */
335333
}
336334
}
337335

@@ -1087,21 +1085,6 @@ export class UserInterface implements ui_constants.UiApi {
10871085
});
10881086
}
10891087

1090-
public logout = (networkInfo :social.SocialNetworkInfo) : Promise<void> => {
1091-
var network = this.model.getNetwork(networkInfo.name);
1092-
// Check if the user is connected to a network
1093-
if (!network) {
1094-
// If the user is not connected to the network, then don't log him out,
1095-
// you probably won't reach this point anyways. EVER. Probably.
1096-
console.warn('User is trying to log out of not-logged-in-network ' +
1097-
networkInfo.name);
1098-
return Promise.resolve<void>();
1099-
}
1100-
1101-
network.logoutExpected = true;
1102-
return this.core.logout(networkInfo);
1103-
}
1104-
11051088
private reconnect_ = (network :string) => {
11061089
this.model.reconnecting = true;
11071090
// TODO: add wechat, quiver, github URLs

0 commit comments

Comments
 (0)