From 6d83bf6f5849d8b504e8e125d50c73cf3a086ec8 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 7 Apr 2021 18:30:26 +0200 Subject: [PATCH] Add settings for user search --- src/models/user.js | 7 +++++++ src/models/userSettings.js | 2 ++ src/store/modules/auth.js | 12 +++++++----- src/views/user/Settings.vue | 17 +++++++++++++---- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/models/user.js b/src/models/user.js index fc7f3dfd..ef6a48ef 100644 --- a/src/models/user.js +++ b/src/models/user.js @@ -1,8 +1,14 @@ import AbstractModel from './abstractModel' +import UserSettingsModel from '@/models/userSettings' export default class UserModel extends AbstractModel { constructor(data) { super(data) + + if (this.settings !== null) { + this.settings = new UserSettingsModel(this.settings) + } + this.created = new Date(this.created) this.updated = new Date(this.updated) } @@ -15,6 +21,7 @@ export default class UserModel extends AbstractModel { name: '', created: null, updated: null, + settings: null, } } diff --git a/src/models/userSettings.js b/src/models/userSettings.js index 2a11061f..d6fe1dfa 100644 --- a/src/models/userSettings.js +++ b/src/models/userSettings.js @@ -6,6 +6,8 @@ export default class UserSettingsModel extends AbstractModel { return { name: '', emailRemindersEnabled: true, + discoverableByName: false, + discoverableByEmail: false, } } } \ No newline at end of file diff --git a/src/store/modules/auth.js b/src/store/modules/auth.js index 2b667365..810dcaab 100644 --- a/src/store/modules/auth.js +++ b/src/store/modules/auth.js @@ -11,6 +11,7 @@ export default { needsTotpPasscode: false, avatarUrl: '', lastUserInfoRefresh: null, + settings: {}, }), mutations: { info(state, info) { @@ -18,10 +19,12 @@ export default { if (info !== null) { state.avatarUrl = info.getAvatarUrl() } + if (info.settings) { + state.settings = info.settings + } }, - setUserSettings(state, {name, emailRemindersEnabled}) { - state.info.name = name - state.info.emailRemindersEnabled = emailRemindersEnabled + setUserSettings(state, settings) { + state.settings = settings }, authenticated(state, authenticated) { state.authenticated = authenticated @@ -176,7 +179,7 @@ export default { authenticated = info.exp >= ts ctx.commit('info', info) - if (authenticated ) { + if (authenticated) { const HTTP = HTTPFactory() // We're not returning the promise here to prevent blocking the initial ui render if the user is // accessing the site with a token in local storage @@ -190,7 +193,6 @@ export default { info.type = ctx.state.info.type info.email = ctx.state.info.email info.exp = ctx.state.info.exp - info.emailRemindersEnabled = ctx.state.info.emailRemindersEnabled ctx.commit('info', info) ctx.commit('authenticated', authenticated) diff --git a/src/views/user/Settings.vue b/src/views/user/Settings.vue index f9f2463b..9608890e 100644 --- a/src/views/user/Settings.vue +++ b/src/views/user/Settings.vue @@ -108,6 +108,18 @@ Send me Reminders for tasks via Email +
+ +
+
+ +