mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 21:49:59 +02:00
Fix: Prevent potential crash when workspace doesn't exist
This commit addresses a potential crash that could occur when the active workspace no longer exists. The issue was that the code attempted to access the `uuid` property of the first workspace in the list even if the list was empty. This commit fixes the issue by using optional chaining (`?.`) to safely access the `uuid` property, ensuring the code doesn't crash if the workspace list is empty.
This commit is contained in:
parent
9bcb66c768
commit
05acfdb27e
1 changed files with 2 additions and 2 deletions
|
@ -62,11 +62,11 @@ var ZenWorkspaces = new class extends ZenMultiWindowFeature {
|
|||
const activeWorkspace = this._workspaceCache.workspaces.find(w => w.uuid === activeWorkspaceId);
|
||||
// Set the active workspace ID to the first one if the one with selected id doesn't exist
|
||||
if (!activeWorkspace) {
|
||||
Services.prefs.setStringPref("zen.workspaces.active", this._workspaceCache.workspaces[0].uuid);
|
||||
Services.prefs.setStringPref("zen.workspaces.active", this._workspaceCache.workspaces[0]?.uuid);
|
||||
}
|
||||
} else {
|
||||
// Set the active workspace ID to the first one if active workspace doesn't exist
|
||||
Services.prefs.setStringPref("zen.workspaces.active", this._workspaceCache.workspaces[0].uuid);
|
||||
Services.prefs.setStringPref("zen.workspaces.active", this._workspaceCache.workspaces[0]?.uuid);
|
||||
}
|
||||
}
|
||||
return this._workspaceCache;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue