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

Commit

Permalink
mo 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 a8a77e3 commit db7324e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
32 changes: 15 additions & 17 deletions apps/mocksi-lite-next/src/pages/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ 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 @@ -91,12 +104,7 @@ chrome.action.onClicked.addListener((tab) => {
message: prevRequest.message,
});
}

if (prevRequest.message === "PLAY") {
chrome.action.setIcon({ path: "play-icon.png", tabId: tab.id });
} else {
chrome.action.setIcon({ path: "mocksi-icon.png", tabId: tab.id });
}
setToolbarIcon(prevRequest.message, tab.id);
} else {
console.log("No tab found, could not mount extension");
}
Expand Down Expand Up @@ -154,17 +162,7 @@ chrome.runtime.onMessageExternal.addListener(
return true;
}

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

chrome.tabs.sendMessage(
tab.id,
Expand Down
2 changes: 0 additions & 2 deletions apps/mocksi-lite-next/src/pages/content/mocksi-extension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,9 @@ chrome.runtime.onMessage.addListener((request) => {
case "MINIMIZED":
styles = {
display: "none",
height: "150px",
/* top right bottom left */
inset: "0px 0px auto auto",
origin: "top right",
width: "400px",
};
break;
case "STOP_PLAYING":
Expand Down

0 comments on commit db7324e

Please sign in to comment.