Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
umair-choudhary committed Jan 26, 2021
1 parent 5f44751 commit 25ae574
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 45 deletions.
76 changes: 39 additions & 37 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,43 +114,45 @@ chrome.runtime.onMessage.addListener(({type, origin}, _, sendResponse) => {

// Listen for 'request-core-access-token' event and respond to the messenger
// with a valid access token. This may trigger a login popup window if needed.
chrome.runtime.onMessage.addListener(({type, origin, isCore}, _, sendResponse) => {
if (type !== 'request-core-access-token') {
return false;
}

renderBackend = isCore
? RenderBackend.Core
: RenderBackend.StorefrontRenderer;

const params = [
[
'scope',
`${shopifyEmployee === true ? 'employee' : ''} ${
env.DEVTOOLS_SCOPE[renderBackend]
} ${COLLABORATORS_SCOPE}`,
],
];

// SFR does not need a destination.
const destination =
renderBackend === RenderBackend.Core ? `${origin}/admin` : '';

const oauth = getOauth2Client(origin);

getSubjectId(oauth, origin)
.then(subjectId => {
return oauth.getSubjectAccessToken(destination, subjectId, params);
})
.then(token => {
sendResponse({token});
})
.catch(error => {
sendResponse({error});
});

return true;
});
chrome.runtime.onMessage.addListener(
({type, origin, isCore}, _, sendResponse) => {
if (type !== 'request-core-access-token') {
return false;
}

renderBackend = isCore
? RenderBackend.Core
: RenderBackend.StorefrontRenderer;

const params = [
[
'scope',
`${shopifyEmployee === true ? 'employee' : ''} ${
env.DEVTOOLS_SCOPE[renderBackend]
} ${COLLABORATORS_SCOPE}`,
],
];

// SFR does not need a destination.
const destination =
renderBackend === RenderBackend.Core ? `${origin}/admin` : '';

const oauth = getOauth2Client(origin);

getSubjectId(oauth, origin)
.then(subjectId => {
return oauth.getSubjectAccessToken(destination, subjectId, params);
})
.then(token => {
sendResponse({token});
})
.catch(error => {
sendResponse({error});
});

return true;
},
);

// Listen for the 'request-user-info' event and respond to the messenger
// with a the given_name of the currently logged in user.
Expand Down
2 changes: 1 addition & 1 deletion src/detectShopify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for (let i = 0; i < scripts.length; i++) {
if (typeof content === 'string') {
if (/Shopify\.shop\s*=/.test(content)) {
hasDetectedShopify = true;
break
break;
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ function determineRenderBackend(): Promise<boolean> {
}
determineRenderBackend()
`,
function (isCore: boolean) {
resolve(isCore)
}
)
})
function(isCore: boolean) {
resolve(isCore);
},
);
});
}

async function refreshPanel() {
Expand Down
10 changes: 8 additions & 2 deletions src/utils/getProfileData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import nullthrows from 'nullthrows';
import {SubjectAccessToken} from 'types';

export async function getProfileData(url: URL, isCore: boolean): Promise<FormattedProfileData> {
export async function getProfileData(
url: URL,
isCore: boolean,
): Promise<FormattedProfileData> {
const parser = new DOMParser();

const fetchOptions = {} as any;
Expand Down Expand Up @@ -31,7 +34,10 @@ function noProfileFound(document: HTMLDocument) {
return document.querySelector('#liquidProfileData') === null;
}

function requestAccessToken({origin}: URL, isCore: boolean): Promise<SubjectAccessToken> {
function requestAccessToken(
{origin}: URL,
isCore: boolean,
): Promise<SubjectAccessToken> {
return new Promise((resolve, reject) => {
return chrome.runtime.sendMessage(
{type: 'request-core-access-token', origin, isCore},
Expand Down

0 comments on commit 25ae574

Please sign in to comment.