Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
a little more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kayla Fitzsimmons authored and Kayla Fitzsimmons committed Aug 28, 2024
1 parent db7324e commit 33c1b85
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
32 changes: 17 additions & 15 deletions apps/mocksi-lite-next/src/pages/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@ let prevRequest = {
message: "INIT",
};

async function setToolbarIcon(message: string, tabId: number) {
if (message === "PLAY") {
await chrome.action.setIcon({
path: "play-icon.png",
tabId,
});
} else {
await chrome.action.setIcon({
path: "mocksi-icon.png",
tabId,
});
}
}
const getAuth = async (): Promise<null | {
accessToken: string;
email: string;
Expand Down Expand Up @@ -104,7 +91,12 @@ chrome.action.onClicked.addListener((tab) => {
message: prevRequest.message,
});
}
setToolbarIcon(prevRequest.message, tab.id);
if (prevRequest.message === "PLAY") {
chrome.action.setIcon({
path: "play-icon.png",
tabId: tab.id,
});
}
} else {
console.log("No tab found, could not mount extension");
}
Expand Down Expand Up @@ -162,7 +154,17 @@ chrome.runtime.onMessageExternal.addListener(
return true;
}

setToolbarIcon(request.message, tab.id);
if (request.message === "PLAY") {
await chrome.action.setIcon({
path: "play-icon.png",
tabId: tab.id,
});
} else if (request.message === "STOP_PLAYING") {
chrome.action.setIcon({
path: "mocksi-icon.png",
tabId: tab.id,
});
}

chrome.tabs.sendMessage(
tab.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ chrome.runtime.onMessage.addListener((request) => {
display: "none",
/* top right bottom left */
inset: "0px 0px auto auto",
origin: "top right",
};
break;
case "STOP_PLAYING":
Expand Down Expand Up @@ -161,6 +160,7 @@ chrome.runtime.onMessage.addListener((request) => {
display: "block",
height: "600px",
width: "500px",
inset: "auto 10px 10px auto",
boxShadow: "none",
zIndex: 99998,
border: "none",
Expand Down

0 comments on commit 33c1b85

Please sign in to comment.