Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2311. #2333

Merged
merged 1 commit into from
Sep 7, 2024
Merged

Fixes #2311. #2333

merged 1 commit into from
Sep 7, 2024

Conversation

corrideat
Copy link
Member

This implements the following changes:

  • Increase KV notification status memory to 2 months
  • Set Vuex notification memory to 6 months
  • Automatically mark notifications as read after the notification status memory window (e.g. after 2 months)
  • Purge notifications from Vuex store that are older than 6 months

@corrideat corrideat requested a review from taoeffect September 6, 2024 20:12
Copy link

cypress bot commented Sep 6, 2024

group-income    Run #3037

Run Properties:  status check passed Passed #3037  •  git commit f36f7519e4 ℹ️: Merge 329e2c73cb1f60f9ce3afb22c8d97e85cc02c9e0 into 41ff6b74ffb8755e5dce8c254226...
Project group-income
Branch Review refs/pull/2333/merge
Run status status check passed Passed #3037
Run duration 10m 55s
Commit git commit f36f7519e4 ℹ️: Merge 329e2c73cb1f60f9ce3afb22c8d97e85cc02c9e0 into 41ff6b74ffb8755e5dce8c254226...
Committer Ricardo Iván Vieitez Parra
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 10
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 111
View all changes introduced in this branch ↗︎

@@ -107,6 +110,7 @@ export function compareOnPriority (notificationA: Notification, notificationB: N
}

export function isExpired (notification: Notification): boolean {
console.error('@@@isExpired', notification, age(notification) > maxAge(notification), age(notification), maxAge(notification), 'read', notification.read)
Copy link
Member

Choose a reason for hiding this comment

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

Stray debug logging.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

Questions

Comment on lines +19 to +21
// Notifications older than MAX_AGE_UNREAD are discarded
if (age(notification) > MAX_AGE_UNREAD) {
return null
Copy link
Member

Choose a reason for hiding this comment

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

OK, they are discarded in the getter, but where are they discarded from the state?

Copy link
Member Author

Choose a reason for hiding this comment

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

They're discarded from the state when the state is saved (see state/vuex/save)

Copy link
Member

Choose a reason for hiding this comment

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

I genuinely do not see where that happens. Can you point it out?

Copy link
Member Author

Choose a reason for hiding this comment

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

The line is literally part of this commit (although the change in question is related but actually a bugfix for a different issue).

https://github.com/okTurtles/group-income/pull/2333/files#diff-170fa1f8952aa138da06e2d0a0e0039fffda8cdf4168989b4886eceaf66d502cR126

As you can see, each time the state is saved, the notifications are filtered.

Copy link
Member

Choose a reason for hiding this comment

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

Then my logic comprehension might be broken. I saw that line and that line doesn't appear to do be related to these changes here as it is accessing the notifications through the state (which is unfiltered) unlike this getter. What am I missing?

Copy link
Member Author

Choose a reason for hiding this comment

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

What am I missing?

You're missing it here:

(which is unfiltered)

The call to applyStorageRules does the filtering. Hence, the only the getter needs to be updated.

Copy link
Member

@taoeffect taoeffect Sep 7, 2024

Choose a reason for hiding this comment

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

OK, thanks, I think I see what you mean, it's this line:

let items = notifications.filter(item => !isExpired({ ...item, ...status[item.hash] }))

And then the status[item.hash] supposedly has the correct value to get maxAge to return MAX_AGE_UNREAD, is my guess. Although per my other question I'm not super clear on how that would have the correct value, but in my tests this seemed to work so I'll go ahead and approve once the stray debug logging is removed. If there are problems we can return to this later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, I'm not sure what's confusing to you, but I can comment on what was somewhat confusing to me.

There are two different things going on: saving or mutating the UI and display concerns. In addition, there notification state is split up into the items and status properties. items is generated when a notification happens, and status mostly (only?) holds the read / unread status.

The 'saving' part is mostly addressed in this PR by adjusting the constants. That was mostly already working (the change I pointed out in state.js didn't entirely work because it looks at the read property, but it wasn't gonna find it because it's usually undefined in items; the change makes it also look into status). In short, saving already filters things out based on age.

This PR addresses the UI part. This has two goals:

  1. Since the read state for notifications that are too old (i.e., between the two windows) will not be saved, it sets read to true for display purposes.
  2. It also filters out notifications that are too old. This is for consistency, but it's not that important since saving the state takes care of removing these old notifications.

frontend/model/notifications/vuexModule.js Show resolved Hide resolved
This implements the following changes:

  * Increase KV notification status memory to 2 months
  * Set Vuex notification memory to 6 months
  * Automatically mark notifications as read after the notification status memory window (e.g. after 2 months)
  * Purge notifications from Vuex store that are older than 6 months
@corrideat corrideat force-pushed the 2311-cannot-mark-notifications-as-read branch from 8e6bce1 to 329e2c7 Compare September 7, 2024 16:56
Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

Great work @corrideat !

@taoeffect taoeffect merged commit b1f60db into master Sep 7, 2024
4 checks passed
@taoeffect taoeffect deleted the 2311-cannot-mark-notifications-as-read branch September 7, 2024 19:27
@taoeffect taoeffect changed the title Fixes #2321. Fixes #2311. Sep 7, 2024
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