Skip to content

Commit

Permalink
Refactor setStatus function and update lastStatusData in Home.svelte,…
Browse files Browse the repository at this point in the history
… client.ts, and background.ts
  • Loading branch information
biplobsd committed Apr 26, 2024
1 parent a5bac3a commit 60f99d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/background/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ export async function parseData(
{ status, to, from }: RuntimeMessage,
sender?: chrome.runtime.MessageSender,
) {
if (to !== "background") {
return;
}

let tabId: number | undefined;
if (sender && sender.tab && sender.tab.id) {
tabId = sender.tab.id;
}

log.info(status);

if (to !== "background") {
return;
}
switch (status.code) {
case "ready":
switch (from) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/pages/Home.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@
}
async function parseData({ status, to }: RuntimeMessage) {
setStatus("...");
if (to !== "option") {
return;
}
setStatus("...");
log.info(status);
setStatus("msg" in status ? status.msg : status.code);
Expand Down
8 changes: 4 additions & 4 deletions src/content/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export async function readySignalSend() {
await runtime.send({
to: "option",
status: {
msg: "Ready for accept request",
msg: "Ready for accept request?",
code: "ready",
},
});
Expand All @@ -281,7 +281,7 @@ async function acceptSignalSend() {
await runtime.send({
to: "option",
status: {
msg: "Ready for accept request",
msg: "Accepting request...",
code: "accept",
},
});
Expand Down Expand Up @@ -396,12 +396,12 @@ async function unSubSubNow(channelID: string) {
}

export async function parseData({ status, to: type }: RuntimeMessage) {
log.info(status);

if (type !== "content") {
return;
}

log.info(status);

switch (status.code) {
case "loading":
isRunning = true;
Expand Down

0 comments on commit 60f99d3

Please sign in to comment.