Skip to content

✨ Feature(notification): refactor notification and add notificationSound settings#1370

Merged
Molunerfinn merged 3 commits intodevfrom
feature-notification-silent
Jan 4, 2026
Merged

✨ Feature(notification): refactor notification and add notificationSound settings#1370
Molunerfinn merged 3 commits intodevfrom
feature-notification-silent

Conversation

@Molunerfinn
Copy link
Owner

ISSUES CLOSED: #1229

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the notification system and adds a notificationSound setting to control whether notification sounds are played. The main changes include converting the renderer-side notification handling to use RPC communication with the main process, adding support for notification callbacks, and updating all notification usages throughout the codebase.

Key Changes

  • Added notificationSound boolean setting to control notification sound behavior (defaults to true)
  • Refactored notification system to use RPC pattern instead of direct Electron Notification API in renderer process
  • Implemented notification callback mechanism to handle click events with automatic cleanup

Reviewed changes

Copilot reviewed 28 out of 33 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/universal/types/view.d.ts Added notificationSound field to settings interface
src/universal/types/types.d.ts Updated notification interfaces to replace icon with text and clickFn with callback
src/universal/types/rpc.d.ts Added IShowNotificationArgs type for RPC notifications
src/universal/types/i18n.d.ts Added i18n key for notification sound setting
src/universal/types/enum.ts Added SHOW_NOTIFICATION RPC action type
src/universal/events/constants.ts Added PICGO_NOTIFICATION_CLICKED event constant
src/renderer/utils/dataSender.ts Converted saveConfig to async/await pattern using invoke
src/renderer/utils/common.ts Refactored showNotification to use RPC with callback support and cleanup logic
src/renderer/pages/*.vue Updated all notification calls to use new object-based API
src/main/utils/common.ts Enhanced showNotification to support silent option based on settings
src/main/lifeCycle/index.ts Updated notification list processing to use refactored function
src/main/events/rpc/routes/system.ts Added RPC handler for notification with callback support
src/main/events/picgoCoreIPC.ts Converted save config IPC to handle pattern
src/main/events/ipcList.ts Updated notification calls to use unified function
src/main/apis/gui/index.ts Updated notification calls to use refactored function
src/main/apis/app/uploader/*.ts Updated notification calls to use refactored function
src/main/apis/app/system/index.ts Updated notification calls to use refactored function
src/main/apis/app/remoteNotice/index.ts Renamed clickFn to callback for consistency
public/i18n/*.yml Added translation strings for notification sound setting
.gitignore Added specs/ directory to ignore list
Comments suppressed due to low confidence (1)

src/main/utils/common.ts:52

  • The callback is always attached to the notification click handler, even when no callback is provided. This creates an unnecessary event listener that checks for a falsy callback on every notification click. Consider only attaching the click handler when a callback is actually provided by checking if options.callback or options.clickToCopy is truthy before calling notification.once('click', handleClick).
  const handleClick = () => {
    if (options.clickToCopy) {
      clipboard.writeText(options.copyContent || body)
    }
    if (options.callback) {
      options.callback()
    }
  }
  notification.once('click', handleClick)
  notification.once('close', () => {
    notification.removeListener('click', handleClick)
  })

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Molunerfinn Molunerfinn merged commit 2936b19 into dev Jan 4, 2026
@Molunerfinn Molunerfinn deleted the feature-notification-silent branch January 4, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Disable/Enable Notifications Sound

2 participants