Skip to content

Commit

Permalink
fix: Error when non-support setting change is received via stream (#5487
Browse files Browse the repository at this point in the history
)
  • Loading branch information
GopalVerma1303 authored Jan 22, 2024
1 parent 0639d22 commit f7e443a
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions app/lib/services/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,31 @@ function connect({ server, logoutOnError = false }: { server: string; logoutOnEr
const { _id, value } = ddpMessage.fields.args[1];
const db = database.active;
const settingsCollection = db.get('settings');
try {
const settingsRecord = await settingsCollection.find(_id);
// @ts-ignore
const { type } = defaultSettings[_id];
if (type) {
await db.write(async () => {
await settingsRecord.update(u => {
// @ts-ignore
u[type] = value;

// Check if the _id exists in defaultSettings
if (defaultSettings.hasOwnProperty(_id)) {
try {
const settingsRecord = await settingsCollection.find(_id);
// @ts-ignore
const { type } = defaultSettings[_id];
if (type) {
await db.write(async () => {
await settingsRecord.update(u => {
// @ts-ignore
u[type] = value;
});
});
});
}
store.dispatch(updateSettings(_id, value));
}
store.dispatch(updateSettings(_id, value));

if (_id === 'Presence_broadcast_disabled') {
setPresenceCap(value);
if (_id === 'Presence_broadcast_disabled') {
setPresenceCap(value);
}
} catch (e) {
log(e);
}
} catch (e) {
log(e);
} else {
console.warn(`Setting with _id '${_id}' is not present in defaultSettings.`);
}
}
})
Expand Down

0 comments on commit f7e443a

Please sign in to comment.