This error message should be used for non fatal errors (otherwise, use the ErrorScene). It is implemented using Svelte and the new "$errorStore". Use `errorStore.addErrorMessage` to display the error popup with the message. This PR uses this error message to display a popup explaining the browser is too old for WebRTC.
24 lines
559 B
TypeScript
24 lines
559 B
TypeScript
import {writable} from "svelte/store";
|
|
|
|
/**
|
|
* A store that contains a list of error messages to be displayed.
|
|
*/
|
|
function createErrorStore() {
|
|
const { subscribe, set, update } = writable<string[]>([]);
|
|
|
|
return {
|
|
subscribe,
|
|
addErrorMessage: (e: string|Error): void => {
|
|
update((messages) => {
|
|
messages.push(e.toString());
|
|
return messages;
|
|
});
|
|
},
|
|
clearMessages: (): void => {
|
|
set([]);
|
|
}
|
|
};
|
|
}
|
|
|
|
export const errorStore = createErrorStore();
|