From 1686663a3f45d1c8184b1164ed681499d24c6ae6 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 21 Mar 2021 18:11:24 +0100 Subject: [PATCH] Add option to remove a list background --- src/services/list.js | 15 ++++++++++++ src/store/index.js | 4 +++ src/views/list/settings/background.vue | 34 +++++++++++++++++++------- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/services/list.js b/src/services/list.js index 41bb3345..22d73088 100644 --- a/src/services/list.js +++ b/src/services/list.js @@ -56,4 +56,19 @@ export default class ListService extends AbstractService { return e }) } + + removeBackground(list) { + const cancel = this.setLoading() + + return this.http.delete(`/lists/${list.id}/background`, list) + .then(response => { + return Promise.resolve(response.data) + }) + .catch(error => { + return this.errorHandler(error) + }) + .finally(() => { + cancel() + }) + } } \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index 20523175..46a88ca0 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -103,6 +103,10 @@ export const store = new Vuex.Store({ } } + if (typeof currentList.backgroundInformation === 'undefined' || currentList.backgroundInformation === null) { + state.background = null + } + // Server updates don't return the right. Therefore the right is reset after updating the list which is // confusing because all the buttons will disappear in that case. To prevent this, we're keeping the right // when updating the list in global state. diff --git a/src/views/list/settings/background.vue b/src/views/list/settings/background.vue index 0c22b759..689905de 100644 --- a/src/views/list/settings/background.vue +++ b/src/views/list/settings/background.vue @@ -6,6 +6,8 @@ class="list-background-setting" :wide="true" v-if="uploadBackgroundEnabled || unsplashBackgroundEnabled" + :tertary="hasBackground ? 'Remove Background' : ''" + @tertary="removeBackground()" >
- {{ backgroundService.loading ? 'Loading...' : 'Load more photos'}} + {{ backgroundService.loading ? 'Loading...' : 'Load more photos' }}