Skip to content

Add priority system to the notification queue - #158

Open
corradedied wants to merge 13 commits into
deividcomsono:mainfrom
corradedied:priority-system
Open

Add priority system to the notification queue#158
corradedied wants to merge 13 commits into
deividcomsono:mainfrom
corradedied:priority-system

Conversation

@corradedied

@corradedied corradedied commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

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 public Notify API (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 Priority field (lower number = more urgent, via the new Library.NotifyPriority enum: 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.

  • InsertNotifyOrdered replaces the plain table.insert at notification creation, searching NotifyOrder to find where the new notification belongs and inserting it there (stable insert, so same-priority notifications keep FIFO order).
  • Reflow/animation is free — UpdateNotificationPositions already 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 existing NotifyTweenInfo tween, 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 original SentAt.
  • Library.NotifyPriorityColors adds 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 on Urgent only). It sits on whichever side faces inward relative to Library.NotifySide — left of the card when docked right (default), right of the card when docked left — and flips live if SetNotifySide is called while it's on screen.

NotifySide = Right

image

NotifySide = Left

image

Implementation notes

  • The indicator's height can't be set with Scale relative to Holder (e.g. UDim2.new(0, 8, 1, 0)) — Holder is AutomaticSize, 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 fixed Offset pixels, kept in sync with Holder's resolved height via a GetPropertyChangedSignal("AbsoluteSize") connection instead of a live Scale relationship. The connection is disconnected in Data:Destroy().
  • Had to introduce an Inner wrapper frame inside Holder to hold the existing content (title/description/timer, previously direct children managed by Holder's UIListLayout). Without it, the indicator — a plain child of Holder — would get swept into the list layout as another stacked row instead of a free-floating sibling.
  • The indicator's UICorner is registered in Library.Corners so it stays in sync with global corner-radius changes, same as Holder's own corner.
  • SetNotifySide now also calls a new Data:RefreshPriorityIndicator() on every live notification (in addition to its existing FakeBackground.AnchorPoint flip), so already-visible urgent indicators flip sides immediately rather than only affecting notifications created after the call.
ezgif-20f1388c0bb87a02
Used test script

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.
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.

1 participant