Skip to content

feat: add notification API wrapper#3096

Merged
MartinCupela merged 12 commits intomasterfrom
feat/notification-api-wrapper
Apr 8, 2026
Merged

feat: add notification API wrapper#3096
MartinCupela merged 12 commits intomasterfrom
feat/notification-api-wrapper

Conversation

@MartinCupela
Copy link
Copy Markdown
Contributor

@MartinCupela MartinCupela commented Apr 6, 2026

BREAKING CHANGE:

  • Removed legacy notification text callback props from Message props:
    getDeleteMessageErrorNotification,
    getFetchReactionsErrorNotification,
    getFlagMessageErrorNotification,
    getFlagMessageSuccessNotification,
    getMarkMessageUnreadErrorNotification,
    getMarkMessageUnreadSuccessNotification,
    getMuteUserErrorNotification,
    getMuteUserSuccessNotification,
    getPinMessageErrorNotification.
    Notification customization must now be done through notification translators
    (Streami18n translationBuilder topic: "notification") and/or custom MessageActions.

BREAKING CHANGE:

  • Message action handlers no longer publish notifications internally.
    Errors now propagate to call sites, which are responsible for success/error notifications.

BREAKING CHANGE:

  • Removed ConnectionStatus component. Connection notification UI is app responsibility now.

🎯 Goal

Summary

This PR introduces a new notifications facade hook: useNotificationApi at src/components/Notifications/hooks/useNotificationApi.ts, and migrates notification API usage in src to use it.
This PR completes the notification-system migration for message and channel-list actions by removing legacy Message-level notification props and moving notification publishing/customization to the modern notification pipeline (Notification + translation builders + customizable action components).

What changed

  1. Added typed notification API wrapper
  • Introduced useNotificationApi(): NotificationApi.
  • Added explicit exported types for reuse:
    • AddNotificationParams
    • NotificationIncidentDescriptor
    • AddNotification
    • RemoveNotification
    • StartNotificationTimeout
    • NotificationApi
  1. Added addNotification abstraction over client.notifications.add
  • Centralizes construction of notification payload/options.
  • Supports:
    • message, emitter, severity, duration, actions, error, context, tags, targetPanels, type, incident.
  • Notification target behavior:
    • Uses inferred panel from useNotificationTarget by default.
    • Allows overriding via targetPanels (including multiple panels).
    • If targetPanels are provided, inferred panel is ignored.
  • Type behavior:
    • Uses provided type as-is.
    • If type is omitted and incident is provided, type is generated from incident descriptor.
    • If type is provided, incident is optional and not required.
  1. Added other wrappers
  • removeNotification(id) delegates to client.notifications.remove(id).
  • startNotificationTimeout(id) delegates to client.notifications.startTimeout(id).
  • addSystemNotification(options) adds Notification with specific system tag
  1. Added useSystemNotifications hook that filters only notifications with tag system

  2. Migrated direct notification manager usage

  1. Added IconMinus component and used it in NumericInput
  2. Introduced fixes to demo app
  3. Message actions
  • Moved action-level success/error notifications to call sites in:
    • src/components/MessageActions/MessageActions.defaults.tsx
    • src/components/MessageActions/RemindMeSubmenu.tsx
  • Added notifications for:
    • pin/unpin
    • mark unread
    • flag
    • mute/unmute
    • delete
    • remind me set/remove
    • save for later add/remove
  • All emitted message-action notifications now include:
    • type (API-ish event key; message actions use api:*)
    • context: { message }
    • error attached on error notifications (when available)
  1. Hook behavior
  • Message action hooks no longer own user-facing notification publication.
  • Errors are allowed to propagate to callers (so callers decide notification UX).
  • Removed banned-user early branch from useFlagHandler as requested.
  1. Reactions fetch handling
  • Added failure notification handling for fetch reactions flow in:
    • src/components/Reactions/hooks/useFetchReactions.ts
  1. Notification component customization
  • Added Notification override support via ComponentContext and wired NotificationList to use it.
  • Fixed ComponentContext.Notification type to support forwarded refs:
    • now expects a ref-capable component (ForwardRefExoticComponent<...RefAttributes<HTMLDivElement>>).
  1. Channel list item actions
  • Added context: { channel } to channel-list action notifications in:
    • src/components/ChannelListItem/ChannelListItemActionButtons.defaults.tsx
  • Added success notifications (alongside existing failures) for:
    • mute/unmute
    • archive/unarchive
    • ban/unban
    • pin/unpin
    • leave
  1. Added SystemNotification component to the demo app

Why

  • Reduces API surface exposure of client.notifications across components.
  • Centralizes tagging/type/origin behavior in one place.
  • Improves consistency and makes future notification behavior changes cheaper.
  • Provides reusable typed contracts for components/plugins using notifications.
  • Have system-related notifications API

@MartinCupela MartinCupela changed the title Feat/notification api wrapper feat: add notification API wrapper Apr 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

Size Change: +5.95 kB (+0.98%)

Total Size: 614 kB

📦 View Changed
Filename Size Change
dist/cjs/emojis.js 2.96 kB +2 B (+0.07%)
dist/cjs/index.js 237 kB +2.09 kB (+0.89%)
dist/cjs/WithAudioPlayback.js 43.2 kB +822 B (+1.94%)
dist/es/emojis.mjs 2.47 kB -2 B (-0.08%)
dist/es/index.mjs 235 kB +2.21 kB (+0.95%)
dist/es/WithAudioPlayback.mjs 43 kB +830 B (+1.97%)
ℹ️ View Unchanged
Filename Size
dist/cjs/audioProcessing.js 1.32 kB
dist/cjs/mp3-encoder.js 1.27 kB
dist/css/emoji-replacement.css 456 B
dist/css/index.css 45 kB
dist/es/audioProcessing.mjs 1.31 kB
dist/es/mp3-encoder.mjs 756 B

compressed-size-action

…age-notification props

- move message action success/error notifications to MessageActions defaults
- bubble action handler errors to callers (no hook-level notification side effects)
- add notification types + context payloads for message and channel-list actions
- add Reminder/SaveForLater notification handling
- allow custom Notification component override with forwardRef typing in ComponentContext
- add examples/tests for translator-based notification customization

BREAKING CHANGE:
- Removed legacy notification text callback props from Message props:
  getDeleteMessageErrorNotification,
  getFetchReactionsErrorNotification,
  getFlagMessageErrorNotification,
  getFlagMessageSuccessNotification,
  getMarkMessageUnreadErrorNotification,
  getMarkMessageUnreadSuccessNotification,
  getMuteUserErrorNotification,
  getMuteUserSuccessNotification,
  getPinMessageErrorNotification.
  Notification customization must now be done through notification translators
  (Streami18n translationBuilder topic: "notification") and/or custom MessageActions.

BREAKING CHANGE:
- Message action handlers no longer publish notifications internally.
  Errors now propagate to call sites, which are responsible for success/error notifications.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 78.02198% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.82%. Comparing base (8b13863) to head (59e1ba4).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ListItem/ChannelListItemActionButtons.defaults.tsx 0.00% 23 Missing ⚠️
...ponents/MessageActions/MessageActions.defaults.tsx 76.38% 17 Missing ⚠️
src/components/MessageActions/RemindMeSubmenu.tsx 68.75% 5 Missing ⚠️
src/components/Location/ShareLocationDialog.tsx 20.00% 4 Missing ⚠️
src/components/Poll/PollActions/EndPollAlert.tsx 0.00% 4 Missing ⚠️
src/components/Notifications/NotificationList.tsx 66.66% 3 Missing ⚠️
src/components/Notifications/Notification.tsx 0.00% 2 Missing ⚠️
...rc/components/Message/hooks/useReactionsFetcher.ts 66.66% 1 Missing ⚠️
...mponents/MessageComposer/hooks/useSubmitHandler.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3096      +/-   ##
==========================================
+ Coverage   80.52%   80.82%   +0.29%     
==========================================
  Files         415      417       +2     
  Lines       11948    12035      +87     
  Branches     3858     3873      +15     
==========================================
+ Hits         9621     9727     +106     
+ Misses       2327     2308      -19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- add addSystemNotification function to the useNotificationApi interface

BREAKING CHANGE:
- Removed ConnectionStatus component. Connection notification UI is app responsibility now.
@MartinCupela MartinCupela merged commit 2060768 into master Apr 8, 2026
8 checks passed
@MartinCupela MartinCupela deleted the feat/notification-api-wrapper branch April 8, 2026 14:59
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.

2 participants