react-notification-system icon indicating copy to clipboard operation
react-notification-system copied to clipboard

Add maximum number of notification shown

Open chungchi300 opened this issue 7 years ago • 2 comments

It is good to have option that

<NotificationSystem max=3 ref="notificationSystem" />

My current simulation of it is

     if (this._notificationSystem.state.notifications.length > 3) {
        let allUIds = this._notificationSystem.state.notifications.map(
          notification => notification.uid
        );

        let keepUIds = this._notificationSystem.state.notifications
          .slice(3)
          .map(notification => notification.uid);
        _.difference(allUIds, keepUIds).map(uid =>
          this._notificationSystem.removeNotification(uid)
        );
      }


chungchi300 avatar Jan 24 '18 07:01 chungchi300

@chungchi300 While this is a good idea, few thing are to be considered.

Setting an upper notification limit is fine.

However if the limit is hit there are few ways to handle this:

  • don't add new notifications,
  • replace least recent notification with new one.

Perhaps we can consider which one is the best approach to support and what are the use cases (yours is one of them).

syndbg avatar Jun 18 '18 16:06 syndbg

I am also looking for something similar although my ideal approach would be to collapse all notifications into a notification carousel container.

If there are arguments against using this pattern I'd be interested in hearing them.

img_2799

evansjohnson avatar Aug 24 '18 18:08 evansjohnson