Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
chore: extract to createManabaTab
Browse files Browse the repository at this point in the history
  • Loading branch information
yudukikun5120 committed Nov 10, 2022
1 parent f89362a commit ef34bb1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/background/assignmentDeadlineNotifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ const getCurrentTab = (callback: (tab: chrome.tabs.Tab) => void) =>
callback(tab)
)

const createManabaTab = (notificationId: string) =>
chrome.tabs.create({
url: `https://manaba.tsukuba.ac.jp/ct/${notificationId}`,
})

chrome.runtime.onMessage.addListener(
({ action, assignmentData }) =>
action === "assignmentDeadlineNotification" &&
Expand All @@ -58,13 +63,9 @@ chrome.alarms.onAlarm.addListener(({ name }) =>

// TODO: Avoidance of the `notificationId` collision of event listeners for `chrome.notifications`.
chrome.notifications.onButtonClicked.addListener((notificationId) =>
chrome.tabs.create({
url: `https://manaba.tsukuba.ac.jp/ct/${notificationId}`,
})
createManabaTab(notificationId)
)

chrome.notifications.onClicked.addListener((notificationId) =>
chrome.tabs.create({
url: `https://manaba.tsukuba.ac.jp/ct/${notificationId}`,
})
createManabaTab(notificationId)
)

0 comments on commit ef34bb1

Please sign in to comment.