Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GIS-866: Search Communication #647

Merged
merged 17 commits into from Jan 7, 2021

lint fixes

  • Loading branch information
fcjr committed Dec 23, 2020
commit 0e512227637bd405f661879a3061461fb495193a
@@ -40,7 +40,7 @@ import tabInfo from './classes/TabInfo';
import metrics from './classes/Metrics';
import account from './classes/Account';
import promoModals from './classes/PromoModals';
import searchMessager from './classes/SearchMessager';
import SearchMessager from './classes/SearchMessager';
// utilities
import { allowAllwaysC2P } from './utils/click2play';
import * as common from './utils/common';
@@ -1655,8 +1655,8 @@ function initializeGhosteryModules() {
* @memberOf Background
*/
function initializeSearchMessageHandler() {
const sm = new searchMessager();
sm.init()
const sm = new SearchMessager();
sm.init();
}

/**
@@ -35,17 +35,17 @@ export default class SearchMessager {

_messageHandler(message, sender, sendResponse) {
if (sender.id !== this.extensionId) {
return;
return false;
}

// allow search extension to refresh token
if (message === "refreshToken") {
if (message === 'refreshToken') {
account.refreshToken()
.then(() => sendResponse({ success: true }))
.catch(error => sendResponse({ success: false, error }));
return true
} else {
log('SearchMessager error: Unhandled message', message);
return true;
}
log('SearchMessager error: Unhandled message', message);
return false;
}
}
@@ -28,7 +28,7 @@ class Api {
}

refreshToken() {
This conversation was marked as resolved by jsignanini

This comment has been minimized.

@jsignanini

jsignanini Jan 4, 2021
Member

@fcjr I'm thinking renaming this to something like refreshTokenAndHandleIsRefreshing to make it super clear what the purpose of this new function is

This comment has been minimized.

@fcjr

fcjr Jan 4, 2021
Author Member

That sounds reasonable, I'll make the change. My thought with just naming it refreshToken was that as an external user of the api class the inner "isRefreshing" state is an implementation detail that external users of the function don't really need to know about, but since this should only be used in special cases anyways there shouldn't be a harm in making it explicit

This comment has been minimized.

@jsignanini

jsignanini Jan 4, 2021
Member

@fcjr actually you do make a good point as it’s only used internally in the other “private” function. Ok you can just leave it as is then. Thanks.

return this._refreshToken().then(this.isRefreshing = false);
return this._refreshToken().then(this.isRefreshing = false); // eslint-disable-line no-return-assign
This conversation was marked as resolved by chrmod

This comment has been minimized.

@chrmod

chrmod Jan 5, 2021
Member

this.isRefreshing is set to false immediately after this._refreshToken is being called - it does not wait for a promise to resolve.

This comment has been minimized.

@chrmod

chrmod Jan 5, 2021
Member

Also, why this.isRefreshing is not set to false by _refreshToken() ?

This conversation was marked as resolved by fcjr

This comment has been minimized.

@chrmod

chrmod Jan 5, 2021
Member

Suggested change
return this._refreshToken().then(this.isRefreshing = false); // eslint-disable-line no-return-assign
return this._refreshToken().then(() => { this.isRefreshing = false; });
}

_refreshToken() {
ProTip! Use n and p to navigate between commits in a pull request.