Skip to content

Commit 711373e

Browse files
committed
Add default icon and load settings lazily
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
1 parent bd141eb commit 711373e

2 files changed

Lines changed: 46 additions & 23 deletions

File tree

src/components/navigation/AppNavigationBoard.vue

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,9 @@
112112
</NcActionButton>
113113
</template>
114114
<NcActionButton v-else-if="!board.archived && board.acl?.length > 0"
115-
:name="t('deck', 'Due date reminders')"
116-
:icon="dueDateReminderIcon"
117-
@click="isDueSubmenuActive=true">
118-
{{ dueDateReminderText }}
115+
icon="icon-sound"
116+
@click="openDueReminderMenu">
117+
{{ t('deck', 'Due date reminders') }}
119118
</NcActionButton>
120119

121120
<NcActionButton v-if="canManage && !isDueSubmenuActive"
@@ -238,6 +237,7 @@ export default {
238237
editColor: '',
239238
isDueSubmenuActive: false,
240239
updateDueSetting: null,
240+
loadingDueReminderSettings: false,
241241
canCreate: canCreateState,
242242
cloneModalOpen: false,
243243
exportModalOpen: false,
@@ -267,25 +267,8 @@ export default {
267267
canLeave() {
268268
return this.board.acl?.find((acl) => acl.participant.uid === this.currentUser?.uid && acl.participant.type === 0) !== undefined
269269
},
270-
dueDateReminderIcon() {
271-
if (this.board.settings['notify-due'] === 'all') {
272-
return 'icon-sound'
273-
} else if (this.board.settings['notify-due'] === 'assigned') {
274-
return 'icon-user'
275-
} else if (this.board.settings['notify-due'] === 'off') {
276-
return 'icon-sound-off'
277-
}
278-
return ''
279-
},
280-
dueDateReminderText() {
281-
if (this.board.settings['notify-due'] === 'all') {
282-
return t('deck', 'All cards')
283-
} else if (this.board.settings['notify-due'] === 'assigned') {
284-
return t('deck', 'Only assigned cards')
285-
} else if (this.board.settings['notify-due'] === 'off') {
286-
return t('deck', 'No reminder')
287-
}
288-
return ''
270+
hasDueDateReminderSetting() {
271+
return ['all', 'assigned', 'off'].includes(this.board.settings?.['notify-due'])
289272
},
290273
isDefaultBoard() {
291274
return this.defaultBoardId === String(this.board.id)
@@ -417,6 +400,24 @@ export default {
417400
cancelEdit(e) {
418401
this.editing = false
419402
},
403+
async openDueReminderMenu() {
404+
this.isDueSubmenuActive = true
405+
406+
if (this.hasDueDateReminderSetting || this.loadingDueReminderSettings) {
407+
return
408+
}
409+
410+
this.loadingDueReminderSettings = true
411+
412+
try {
413+
await this.$store.dispatch('hydrateBoardSettings', this.board.id)
414+
} catch (error) {
415+
OC.Notification.showTemporary(t('deck', 'Failed to load due date reminder settings'))
416+
console.error(error)
417+
} finally {
418+
this.loadingDueReminderSettings = false
419+
}
420+
},
420421
async updateSetting(key, value) {
421422
this.updateDueSetting = value
422423
const setting = {}

src/store/main.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,23 @@ export default function storeFactory() {
252252
setCurrentCard(state, card) {
253253
state.currentCard = card
254254
},
255+
setBoardSettings(state, { boardId, settings }) {
256+
const indexExisting = state.boards.findIndex((board) => board.id === boardId)
257+
258+
if (indexExisting > -1) {
259+
Vue.set(state.boards[indexExisting], 'settings', {
260+
...(state.boards[indexExisting].settings || {}),
261+
...settings,
262+
})
263+
}
264+
265+
if (state.currentBoard?.id === boardId) {
266+
Vue.set(state.currentBoard, 'settings', {
267+
...(state.currentBoard.settings || {}),
268+
...settings,
269+
})
270+
}
271+
},
255272

256273
// label mutators
257274
removeLabelFromCurrentBoard(state, labelId) {
@@ -309,6 +326,11 @@ export default function storeFactory() {
309326
setFullApp({ commit }, isFullApp) {
310327
commit('setFullApp', isFullApp)
311328
},
329+
async hydrateBoardSettings({ commit }, boardId) {
330+
const board = await apiClient.loadById(boardId)
331+
commit('setBoardSettings', { boardId, settings: board.settings || {} })
332+
return board.settings || {}
333+
},
312334
async setConfig({ commit }, config) {
313335
for (const key in config) {
314336
try {

0 commit comments

Comments
 (0)