Adding a global error message
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.
This commit is contained in:
parent
a8b91561dc
commit
f4ed527fe8
5 changed files with 93 additions and 1 deletions
|
@ -4,6 +4,8 @@ import {localUserStore} from "../Connexion/LocalUserStore";
|
|||
import {ITiledMapGroupLayer, ITiledMapObjectLayer, ITiledMapTileLayer} from "../Phaser/Map/ITiledMap";
|
||||
import {userMovingStore} from "./GameStore";
|
||||
import {HtmlUtils} from "../WebRtc/HtmlUtils";
|
||||
import {BrowserTooOldError} from "./Errors/BrowserTooOldError";
|
||||
import {errorStore} from "./ErrorStore";
|
||||
|
||||
/**
|
||||
* A store that contains the camera state requested by the user (on or off).
|
||||
|
@ -423,7 +425,7 @@ export const localStreamStore = derived<Readable<MediaStreamConstraints>, LocalS
|
|||
//throw new Error('Unable to access your camera or microphone. Your browser is too old.');
|
||||
set({
|
||||
type: 'error',
|
||||
error: new Error('Unable to access your camera or microphone. Your browser is too old. Please consider upgrading your browser or try using a recent version of Chrome.'),
|
||||
error: new BrowserTooOldError(),
|
||||
constraints
|
||||
});
|
||||
return;
|
||||
|
@ -594,3 +596,11 @@ microphoneListStore.subscribe((devices) => {
|
|||
audioConstraintStore.setDeviceId(undefined);
|
||||
}
|
||||
});
|
||||
|
||||
localStreamStore.subscribe(streamResult => {
|
||||
if (streamResult.type === 'error') {
|
||||
if (streamResult.error.name === BrowserTooOldError.NAME) {
|
||||
errorStore.addErrorMessage(streamResult.error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue