Skip to content

Commit

Permalink
fix(settings): Prevent undefined related errors for encryption
Browse files Browse the repository at this point in the history
`Object.entries([])` would return an empty array, that leads to the `find`
return undefined.

`encryptionReady` and `encryptionEnabled` also returns undefined when no
encryption module is available or functional (I guess).

Signed-off-by: nfebe <fenn25.fn@gmail.com>
  • Loading branch information
nfebe committed Nov 11, 2024
1 parent a3be6ce commit 038deb4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions apps/settings/src/components/Encryption.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,24 @@ export default {
},
data() {
const encryptionModules = loadState('settings', 'encryption-modules')
let defaultCheckedModule = ''
if (encryptionModules instanceof Array && encryptionModules.length > 0) {
const defaultModule = Object.entries(encryptionModules).find((module) => module[1].default)
if (defaultModule) {
defaultCheckedModule = foundModule[0]
}
} else {
logger.debug('No encryption module loaded or enabled')
}
return {
encryptionReady: loadState('settings', 'encryption-ready'),
encryptionEnabled: loadState('settings', 'encryption-enabled'),
encryptionReady: loadState('settings', 'encryption-ready', false),
encryptionEnabled: loadState('settings', 'encryption-enabled', false),
externalBackendsEnabled: loadState('settings', 'external-backends-enabled'),
encryptionAdminDoc: loadState('settings', 'encryption-admin-doc'),
encryptionModules,
shouldDisplayWarning: false,
migrating: false,
defaultCheckedModule: Object.entries(encryptionModules).find((module) => module[1].default)[0],
defaultCheckedModule,
}
},
methods: {
Expand Down

0 comments on commit 038deb4

Please sign in to comment.