Add priority system to the notification queue - #158
Open
corradedied wants to merge 13 commits into
Open
Conversation
Urgent notifications now sort above normal ones and reorder in place (with animation) when a higher-priority toast appears. Toasts within the same priority are broken up by send time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current system only supports FIFO (
First-In, First-Out) ordering — every notification is appended to the bottom regardless of importance, so a genuinely urgent alert could get buried under a stack of routine ones with no way to surface it. This adds a lightweight priority concept without introducing a new animation system or restructuring the publicNotifyAPI (it's purely an additive, optional field).Changes
Check the commit line comments or the comment notifications/conversations below this PR message for some additional technical details about the implementation
Notifications now carry a
Priorityfield (lower number = more urgent, via the newLibrary.NotifyPriorityenum:Urgent = 0,Normal = 1,Low = 2, though raw numbers work too). When a notification is created, it's inserted into the display order at the correct sorted position — by priority first, then by send time — instead of always being appended to the end.InsertNotifyOrderedreplaces the plaintable.insertat notification creation, searchingNotifyOrderto find where the new notification belongs and inserting it there (stable insert, so same-priority notifications keep FIFO order).UpdateNotificationPositionsalready tweens any notification whose target Y-position changes, so once the order list is correct, urgent notifications visually push existing ones down using the library's existingNotifyTweenInfotween, no new animation code required.Data:SetPriority(newPriority)lets a notification's priority be changed live after it's already showing, live-reordering it while preserving its originalSentAt.Library.NotifyPriorityColorsadds an optional priority indicator: a small rounded frame sitting just outside the card (not overlapping any content), matching the card's corner radius and outline styling but colored per priority tier (defaults to red onUrgentonly). It sits on whichever side faces inward relative toLibrary.NotifySide— left of the card when docked right (default), right of the card when docked left — and flips live ifSetNotifySideis called while it's on screen.NotifySide = RightNotifySide = LeftImplementation notes
Holder(e.g.UDim2.new(0, 8, 1, 0)) —HolderisAutomaticSize, so its height is computed from its children, and a child whose height is a scale of that same computed height creates a feedback loop that grows unbounded each layout pass (this actually occurred briefly and produced a stripe stretching the full screen height). Fixed by sizing the indicator in fixedOffsetpixels, kept in sync withHolder's resolved height via aGetPropertyChangedSignal("AbsoluteSize")connection instead of a live Scale relationship. The connection is disconnected inData:Destroy().Innerwrapper frame insideHolderto hold the existing content (title/description/timer, previously direct children managed byHolder'sUIListLayout). Without it, the indicator — a plain child ofHolder— would get swept into the list layout as another stacked row instead of a free-floating sibling.UICorneris registered inLibrary.Cornersso it stays in sync with global corner-radius changes, same asHolder's own corner.SetNotifySidenow also calls a newData:RefreshPriorityIndicator()on every live notification (in addition to its existingFakeBackground.AnchorPointflip), so already-visible urgent indicators flip sides immediately rather than only affecting notifications created after the call.Used test script