Skip to content

Remove use of actionCall, fix updateViewed, manage state with objects…#375

Merged
danjm merged 5 commits intowhats-new-notificationsfrom
whats-new-notifications-patch-1
Mar 9, 2021
Merged

Remove use of actionCall, fix updateViewed, manage state with objects…#375
danjm merged 5 commits intowhats-new-notificationsfrom
whats-new-notifications-patch-1

Conversation

@danjm
Copy link
Contributor

@danjm danjm commented Mar 4, 2021

Compares to #329

This PR makes some changes to the NotificationsController added with #329

The following changes are made:

  • The actionCall method, and therefore the actionFunction property are removed. These will be handled on the client side.
  • With the removal of these methods, the action interface can be removed and the Notification interface can be simplified
  • Notifications are now stored in state via an object, which simplifies the code for retrieving and updating state
  • A fix is made within the updateViewed method

@danjm danjm requested a review from a team as a code owner March 4, 2021 06:22
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

Unit tests appear to be failing.

Also, the config and the state of this controller seem redundant 🤔 I noticed that the state is changing as notifications are seen, but the config remains unchanged (with its original isShown values intact).

Maybe it would make more sense for the notification metadata to be in the config, and just the isShown value stored in state? Or if it's more convenient to have all of the metadata in state, we can leave the redundancy there for now (until the migration to the new base controller), and just eliminate isShown from the notification config (or eliminate the config completely? 🤷 ).

*/
export interface NotificationConfig extends BaseConfig{
allNotifications: Notification[];
allNotifications: NotificationMap | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Why | undefined? I wouldn't expect this controller to be constructed in the first place if there are no notifications

Copy link
Contributor Author

@danjm danjm Mar 5, 2021

Choose a reason for hiding this comment

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

Removed in 0081fa4 (This was left over from when I was anticipating a possible need to only add notifications at some point after the controller had been constructed, via another public method. But it turns out we won't be doing that.)

@danjm
Copy link
Contributor Author

danjm commented Mar 5, 2021

@Gudahtt isShown is removed from config, and only stored on state, in b18365f

@danjm danjm force-pushed the whats-new-notifications-patch-1 branch from 371db50 to 9bb13f5 Compare March 5, 2021 12:02
@danjm danjm merged commit 5dc1627 into whats-new-notifications Mar 9, 2021
@danjm danjm deleted the whats-new-notifications-patch-1 branch March 9, 2021 09:08
NiranjanaBinoy pushed a commit that referenced this pull request Mar 12, 2021
#375)

* Remove use of actionCall, fix updateViewed, manage state with objects instead of arrays, simplify types

* Only store isShown in state, not in the config

* Remove undefined possibility from the allNotifications type

* Fix NotificationController tests

* Fix logic in NotificationController _addNotifications: ensure current state notifications are not deleted.
NiranjanaBinoy pushed a commit that referenced this pull request Mar 18, 2021
#375)

* Remove use of actionCall, fix updateViewed, manage state with objects instead of arrays, simplify types

* Only store isShown in state, not in the config

* Remove undefined possibility from the allNotifications type

* Fix NotificationController tests

* Fix logic in NotificationController _addNotifications: ensure current state notifications are not deleted.
NiranjanaBinoy pushed a commit that referenced this pull request Mar 19, 2021
#375)

* Remove use of actionCall, fix updateViewed, manage state with objects instead of arrays, simplify types

* Only store isShown in state, not in the config

* Remove undefined possibility from the allNotifications type

* Fix NotificationController tests

* Fix logic in NotificationController _addNotifications: ensure current state notifications are not deleted.
NiranjanaBinoy pushed a commit that referenced this pull request Mar 19, 2021
#375)

* Remove use of actionCall, fix updateViewed, manage state with objects instead of arrays, simplify types

* Only store isShown in state, not in the config

* Remove undefined possibility from the allNotifications type

* Fix NotificationController tests

* Fix logic in NotificationController _addNotifications: ensure current state notifications are not deleted.
NiranjanaBinoy pushed a commit that referenced this pull request Mar 19, 2021
#375)

* Remove use of actionCall, fix updateViewed, manage state with objects instead of arrays, simplify types

* Only store isShown in state, not in the config

* Remove undefined possibility from the allNotifications type

* Fix NotificationController tests

* Fix logic in NotificationController _addNotifications: ensure current state notifications are not deleted.
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