Skip to content

Commit

Permalink
feat: remove all alerms on signout (#50)
Browse files Browse the repository at this point in the history
feat: remove all alerms and events on signout
  • Loading branch information
Leko committed Feb 11, 2023
1 parent 8ebb0c1 commit 13cae66
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from "./calendar";
import { loadConfig } from "./config";
import {
clearAllEvents,
getAllEvents,
getEvent,
isOpened,
Expand Down Expand Up @@ -48,6 +49,8 @@ async function dispatch(message: IncomingMessage) {
new Promise<void>((resolve) =>
chrome.identity.clearAllCachedAuthTokens(resolve)
),
chrome.alarms.clearAll(),
clearAllEvents(),
]);
return;
}
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export function useAuth() {
chrome.runtime.sendMessage({ type: "SignInRequest" });
}, []);
const signOut = useCallback(() => {
chrome.runtime.sendMessage({ type: "SignOutRequest" });
setIsAuthenticated(false);
chrome.runtime.sendMessage({ type: "SignOutRequest" }).then(() => {
setIsAuthenticated(false);
});
}, []);

useEffect(() => {
Expand Down
4 changes: 4 additions & 0 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export type ScheduledEvent = {
const KEY_EVETNS = "events_1";
const KEY_OPENED = "opened";

export async function clearAllEvents(): Promise<void> {
await chrome.storage.local.remove([KEY_EVETNS, KEY_OPENED]);
}

export async function upsertEvent(
id: string,
newValue: ScheduledEvent
Expand Down

1 comment on commit 13cae66

@vercel
Copy link

@vercel vercel bot commented on 13cae66 Feb 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.