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

Commit

Permalink
fix: reset the recording state whenever storage change event changes …
Browse files Browse the repository at this point in the history
…the auth state (#86)

Resolves [MOC-62]

Reviewed-by: @schowdhuri

Co-authored-by: David <[email protected]>
  • Loading branch information
schowdhuri and david-saint authored Jul 9, 2024
1 parent c5d02d7 commit b18d700
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apps/mocksi-lite/content/content.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ReactDOM from "react-dom/client";
import {
MOCKSI_AUTH,
MOCKSI_RECORDING_STATE,
RecordingState,
STORAGE_CHANGE_EVENT,
Expand Down Expand Up @@ -108,5 +109,17 @@ window.addEventListener("message", (event: MessageEvent) => {
chrome.storage.local.set({ [eventData.key]: eventData.value }).then(() => {
console.log(eventData.key, " set.");
});

if (eventData.key === MOCKSI_AUTH) {
chrome.storage.local.get([MOCKSI_RECORDING_STATE], (results) => {
const recordingState: RecordingState | null =
results[MOCKSI_RECORDING_STATE];
if (recordingState === RecordingState.UNAUTHORIZED) {
chrome.storage.local.set({
[MOCKSI_RECORDING_STATE]: RecordingState.READY,
});
}
});
}
}
});

0 comments on commit b18d700

Please sign in to comment.