mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-14 11:37:43 +00:00
fix(web): handle 'unload' message while attempting model 'load'
Fixes: KEYMAN-WEB-MD Build-bot: skip build:web Test-bot: skip
This commit is contained in:
parent
5ed4ccb7ef
commit
18f334a60e
1 changed files with 12 additions and 1 deletions
|
|
@ -267,7 +267,11 @@ export class LMLayerWorker {
|
|||
try {
|
||||
this._importScripts(url);
|
||||
} catch (err) {
|
||||
// Does not catch errors thrown within the imported script.
|
||||
// Does catch errors with the model script's file-path.
|
||||
this.error("Error occurred when attempting to load dictionary", err);
|
||||
|
||||
// Remain in the model-unloaded state; the load attempt was unsuccessful.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +316,14 @@ export class LMLayerWorker {
|
|||
this.state = {
|
||||
name: 'modelless',
|
||||
handleMessage: (payload) => {
|
||||
// ...that message must have been 'load'!
|
||||
// It is possible to remain in this state after a model loading error.
|
||||
// In such cases, the hosting engine may signal a model-unload.
|
||||
if (payload.message === 'unload') {
|
||||
// We are already in a "model unloaded" state; no work needed!
|
||||
return;
|
||||
}
|
||||
|
||||
// ...otherwise, that message must have been 'load'!
|
||||
if (payload.message !== 'load') {
|
||||
throw new Error(`invalid message; expected 'load' but got ${payload.message}`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue