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

Migrate alerter to "User Notifications" framework #114

Merged
merged 4 commits into from
Jan 14, 2022
Merged

Conversation

rundong08
Copy link
Collaborator

Fixes #113

Known issues:

  1. Can only send "Banner" notifications by default
  2. Does not support sending a notification with the same group ID as existing ones. But fortunately our use case does not need this.

@@ -42,7 +42,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.8.1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Were these supposed to go back a version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! I am not sure why my flutter decided to roll those versions back...

taqo_client/macos/alerter/Info.plist Show resolved Hide resolved
if(options[@"closeLabel"]){
userNotification.otherButtonTitle = options[@"closeLabel"];
if (options[@"groupID"] && [self notificationWithGroupIdExists:options[@"groupID"]]) {
NSLog(@"Sending notification with the same groupID as existing ones is not supported.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you say more about this switch from removing old notifications with a matching GroupID to exiting ? Is it just not implemented or is there another issue as well that makes it unsupported?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We still support removing old notifications with a matching GroupID, implemented at line 154-157. What we don't support here was sending a notification with the same groupID as an existing one.

In the old alerter, when sending a notification with the same groupID as an existing one, the existing one will be removed before the new one get displayed. However, for us it will make monitoring notification removal subject to race conditions (concurrent editing of an object tracking notifications and removals). A careful design with some locks might eliminate these race conditions, but currently we don't actually need this feature.

Note that if we don't use a tracking object to track notifications and removals, but instead periodically check whether the corresponding notification is still present, as what is done in the old alerter, then the above race conditions could be eliminated. However, that will potentially cause new race conditions since it is unknown whether the notification action callback will be called before the notification disappearance being detected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just realized I could maybe combine the tracking object with periodically checking whether the corresponding notification is still present. So when the notification disappears, the detector will know whether it was caused by removal.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The case I was thinking of was two triggers within a Data Collector that overlapped, for example a Schedule and an Event Trigger. We would want to ensure that the latest one wins. I think. So, would that be the case for removal of an existing for the same Group ID?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

During my trying (to enable sending notifications with the same groupID), I sometimes encounter an issue: when I consecutively and quickly send multiple notifications with the same groupID and quickly click the notification of the last one, the alerter will hang... So for now let's just keep it as is.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this ready for checkin? Or are you doing other work on it still?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry for the delayed updates. It is not ready yet. I was still working on the bug we discovered this morning.

@BobEvans
Copy link
Collaborator

BobEvans commented Dec 15, 2021 via email

@rundong08
Copy link
Collaborator Author

Now the code are there, just need to add proper copyright notice and license text before merging

@BobEvans BobEvans merged commit dd7c679 into develop Jan 14, 2022
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.

Migrate alerter to "User Notifications" framework
2 participants