You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-28 15:22:05 +03:00
Always display verification request toasts on top
As they're interactive and time-sensitive. Fixes https://github.com/vector-im/riot-web/issues/12141
This commit is contained in:
@ -1524,6 +1524,7 @@ export default createReactClass({
|
|||||||
icon: "verification",
|
icon: "verification",
|
||||||
props: {request},
|
props: {request},
|
||||||
component: sdk.getComponent("toasts.VerificationRequestToast"),
|
component: sdk.getComponent("toasts.VerificationRequestToast"),
|
||||||
|
priority: ToastStore.PRIORITY_REALTIME,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -20,6 +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_DEFAULT = 0;
|
||||||
|
|
||||||
static sharedInstance() {
|
static sharedInstance() {
|
||||||
if (!global.mx_ToastStore) global.mx_ToastStore = new ToastStore();
|
if (!global.mx_ToastStore) global.mx_ToastStore = new ToastStore();
|
||||||
return global.mx_ToastStore;
|
return global.mx_ToastStore;
|
||||||
@ -36,9 +39,16 @@ export default class ToastStore extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addOrReplaceToast(newToast) {
|
addOrReplaceToast(newToast) {
|
||||||
|
if (newToast.priority === undefined) newToast.priority = ToastStore.PRIORITY_DEFAULT;
|
||||||
|
|
||||||
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) {
|
||||||
this._toasts.push(newToast);
|
// we only have two priorities so just push realtime ones onto the front
|
||||||
|
if (newToast.priority) {
|
||||||
|
this._toasts.unshift(newToast);
|
||||||
|
} else {
|
||||||
|
this._toasts.push(newToast);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this._toasts[oldIndex] = newToast;
|
this._toasts[oldIndex] = newToast;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user