You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-13 08:02:38 +03:00
Make new device toasts appear above review toasts
...but below incoming verification toasts, which means we now need to actually handle priority insertion correctly. Oh well. Fixes https://github.com/vector-im/riot-web/issues/13442
This commit is contained in:
@@ -267,6 +267,7 @@ export default class DeviceListener {
|
|||||||
key: OTHER_DEVICES_TOAST_KEY,
|
key: OTHER_DEVICES_TOAST_KEY,
|
||||||
title: _t("Review where you’re logged in"),
|
title: _t("Review where you’re logged in"),
|
||||||
icon: "verification_warning",
|
icon: "verification_warning",
|
||||||
|
priority: ToastStore.PRIORITY_LOW,
|
||||||
props: {
|
props: {
|
||||||
deviceIds: oldUnverifiedDeviceIds,
|
deviceIds: oldUnverifiedDeviceIds,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ import EventEmitter from 'events';
|
|||||||
* Holds the active toasts
|
* Holds the active toasts
|
||||||
*/
|
*/
|
||||||
export default class ToastStore extends EventEmitter {
|
export default class ToastStore extends EventEmitter {
|
||||||
static PRIORITY_REALTIME = 1;
|
static PRIORITY_REALTIME = 0;
|
||||||
static PRIORITY_DEFAULT = 0;
|
static PRIORITY_DEFAULT = 1;
|
||||||
|
static PRIORITY_LOW = 2;
|
||||||
|
|
||||||
static sharedInstance() {
|
static sharedInstance() {
|
||||||
if (!global.mx_ToastStore) global.mx_ToastStore = new ToastStore();
|
if (!global.mx_ToastStore) global.mx_ToastStore = new ToastStore();
|
||||||
@@ -43,12 +44,9 @@ export default class ToastStore extends EventEmitter {
|
|||||||
|
|
||||||
const oldIndex = this._toasts.findIndex(t => t.key === newToast.key);
|
const oldIndex = this._toasts.findIndex(t => t.key === newToast.key);
|
||||||
if (oldIndex === -1) {
|
if (oldIndex === -1) {
|
||||||
// we only have two priorities so just push realtime ones onto the front
|
let newIndex = this._toasts.length;
|
||||||
if (newToast.priority) {
|
while (newIndex > 0 && this._toasts[newIndex - 1].priority > newToast.priority) --newIndex;
|
||||||
this._toasts.unshift(newToast);
|
this._toasts.splice(newIndex, 0, newToast);
|
||||||
} else {
|
|
||||||
this._toasts.push(newToast);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this._toasts[oldIndex] = newToast;
|
this._toasts[oldIndex] = newToast;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user