Skip to content

Commit

Permalink
fixed notification buttons not work
Browse files Browse the repository at this point in the history
  • Loading branch information
eric2788 committed Mar 22, 2024
1 parent add3e8a commit 15a1a16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/background/messages/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { PlasmoMessaging } from "@plasmohq/messaging"

import icon from 'raw:assets/icon.png'

export type RequestBody = Partial<chrome.notifications.NotificationOptions<true>> & {
export type RequestBody = Partial<Omit<chrome.notifications.NotificationOptions<true>, 'buttons'>> & {
messages?: string[],
buttons?: (chrome.notifications.ButtonOptions & { clicked: (id: string, index: number) => void })[],
onClicked?: (id: string) => void
}
Expand All @@ -20,11 +21,12 @@ async function createNotification(option: chrome.notifications.NotificationOptio
}

const handler: PlasmoMessaging.MessageHandler<RequestBody, string> = async (req, res) => {
const { title, message, type, buttons, onClicked, ...option } = req.body
const { title, message, messages, type, buttons, onClicked, ...option } = req.body
const id = await createNotification({
type: type ?? 'basic',
title,
message,
message: message ?? messages?.join('\n') ?? '',
buttons: buttons?.map(({ clicked, ...option }) => option),
...option,
iconUrl: icon
})
Expand Down
2 changes: 1 addition & 1 deletion src/background/update-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ getSettingStorage('settings.version').then(async (settings) => {
await sendInternal('notify', {
type: 'list',
title: 'bilibili-vup-stream-enhancer 已推出新版本',
message: `当前版本: v${currentVersion}`,
items: [
{ title: '当前版本', message: `v${currentVersion}` },
{ title: '最新版本', message: `v${latest.tag_name}` },
{ title: '发布日期', message: new Date(latest.published_at).toDateString() }
],
Expand Down

0 comments on commit 15a1a16

Please sign in to comment.