forked from Blendman974/faceclaw
[verified] fix: hide notification background only on screen wake
This commit is contained in:
1 parent
22df4d76d9
commit
9ddc864b0d
6 files changed
+75
-20
No files matched your search
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
export interface NotificationModalHost<M> {
|
||||
/** Create and stack a modal showing this notification. */
|
||||
open(notificationKey: string): M;
|
||||
open(notificationKey: string, hideBackground: boolean): M;
|
||||
/** Whether a queued notification is still worth opening (not dismissed, popups still on). */
|
||||
isAvailable(notificationKey: string): boolean;
|
||||
/** Put the screen back to sleep. */
|
||||
@@ -20,6 +20,8 @@ interface Entry {
|
||||
readonly notificationKey: string;
|
||||
/** Whether this notification woke the screen, so closing the last modal sleeps again. */
|
||||
readonly wokeScreen: boolean;
|
||||
/** Arrival-time state, independent of the inherited return-to-sleep flag. */
|
||||
readonly hideBackground: boolean;
|
||||
}
|
||||
|
||||
export class NotificationModalQueue<M> {
|
||||
@@ -37,11 +39,14 @@ export class NotificationModalQueue<M> {
|
||||
if (this.current) {
|
||||
if (this.current.notificationKey !== notificationKey
|
||||
&& !this.queued.some((entry) => entry.notificationKey === notificationKey)) {
|
||||
this.queued.push({ notificationKey, wokeScreen });
|
||||
this.queued.push({ notificationKey, wokeScreen, hideBackground: wokeScreen });
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.current = { modal: this.host.open(notificationKey), notificationKey, wokeScreen };
|
||||
this.current = {
|
||||
modal: this.host.open(notificationKey, wokeScreen),
|
||||
notificationKey, wokeScreen, hideBackground: wokeScreen,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +99,11 @@ export class NotificationModalQueue<M> {
|
||||
while (this.queued.length > 0) {
|
||||
const next = this.queued.shift()!;
|
||||
if (!this.host.isAvailable(next.notificationKey)) continue;
|
||||
this.post(next.notificationKey, wokeScreen || next.wokeScreen);
|
||||
this.current = {
|
||||
...next,
|
||||
wokeScreen: wokeScreen || next.wokeScreen,
|
||||
modal: this.host.open(next.notificationKey, next.hideBackground),
|
||||
};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user