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

Simplify and remove the notification "cache" #4508

Merged
merged 1 commit into from
May 16, 2022
Merged

Conversation

claucambra
Copy link
Collaborator

@claucambra claucambra commented May 9, 2022

This PR removes removes the notification cache entirely and replaces it with a QSet in UserModel.

The notification "cache"'s only purpose was to keep track of notifications which had already been notified, and it kept track of these by storing randomly-generated hashes composed of the notification text in an internal QSet. The new QSet serves the same functionality as the notification "cache" but instead stores notifications' actual ids, letting us actually filter out notifications which are the same without unintended side-effects. It also obviates the need for custom setters/getters/clearers and therefore the entire notification cache can be removed altogether. Since we didn't actually cache any notifications, we can simplify the code this way.

@claucambra claucambra force-pushed the bugfix/notifications branch from b03abf0 to ab4b37c Compare May 9, 2022 16:15
@claucambra claucambra self-assigned this May 9, 2022
@claucambra claucambra force-pushed the bugfix/notifications branch 2 times, most recently from 53348ff to 1f26247 Compare May 10, 2022 08:55
@claucambra claucambra changed the title Fix notifications not being shown when they should be Simplify and remove the notification "cache" May 10, 2022
src/gui/owncloudgui.cpp Outdated Show resolved Hide resolved
@@ -505,7 +501,8 @@ void User::slotAddErrorToGui(const QString &folderAlias, SyncFileItem::Status st
// add 'other errors' to activity list
_activityModel->addErrorToActivityList(activity);

showDesktopNotification(activity._subject, activity._message);
// Error notifications don't have ids by themselves so we will create one for it
showDesktopNotification(activity._subject, activity._message, qHash(activity._subject + activity._message));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am wondering if collisions could be possible
there is also the option of asking the server teams to add the missing ids

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since errors in this case are created locally I don't think this would be possible

What I have done is instead assign errors with negative ids since activity ids are unsigned ints and therefore always positive. No possibility of collision this way. We also no longer randomly generate error activity ids, but instead create them as increasingly negative numbers

@claucambra claucambra force-pushed the bugfix/notifications branch from 1f26247 to 84e28bf Compare May 13, 2022 15:02
@claucambra claucambra requested a review from mgallien May 13, 2022 15:04
@allexzander allexzander self-requested a review May 16, 2022 10:43
@claucambra claucambra force-pushed the bugfix/notifications branch from 84e28bf to c4e32f1 Compare May 16, 2022 11:29
@claucambra claucambra force-pushed the bugfix/notifications branch 2 times, most recently from de8e2de to 0988100 Compare May 16, 2022 12:26
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
@claucambra claucambra force-pushed the bugfix/notifications branch from 0988100 to b6def51 Compare May 16, 2022 12:28
@sonarcloud
Copy link

sonarcloud bot commented May 16, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@claucambra claucambra merged commit 71439f2 into master May 16, 2022
@claucambra claucambra deleted the bugfix/notifications branch May 16, 2022 13:46
@nextcloud-desktop-bot
Copy link

AppImage file: Nextcloud-PR-4508-b6def519457239bff6d5dcfcf7ccf7d99d2771d0-x86_64.AppImage

To test this change/fix you can simply download above AppImage file and test it.

Please make sure to quit your existing Nextcloud app and backup your data.

@mgallien mgallien added this to the 3.6.0 milestone May 16, 2022
@claucambra
Copy link
Collaborator Author

/backport to stable-3.5

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.

5 participants