diff --git a/package-lock.json b/package-lock.json index 3b6bbc922..88567a9d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2560,6 +2560,21 @@ } } }, + "@nextcloud/browser-storage": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@nextcloud/browser-storage/-/browser-storage-0.1.1.tgz", + "integrity": "sha512-bWzs/A44rEK8b3CMOFw0ZhsenagrWdsB902LOEwmlMCcFysiFgWiOPbF4/0/ODlOYjvPrO02wf6RigWtb8P+gA==", + "requires": { + "core-js": "3.6.1" + }, + "dependencies": { + "core-js": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.1.tgz", + "integrity": "sha512-186WjSik2iTGfDjfdCZAxv2ormxtKgemjC3SI6PL31qOA0j5LhTDVjHChccoc7brwLvpvLPiMyRlcO88C4l1QQ==" + } + } + }, "@nextcloud/browserslist-config": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@nextcloud/browserslist-config/-/browserslist-config-1.0.0.tgz", diff --git a/package.json b/package.json index 168473d5d..3d8e88f41 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@juliushaertl/vue-richtext": "^0.3.1", "@nextcloud/auth": "^1.2.3", "@nextcloud/axios": "^1.3.2", + "@nextcloud/browser-storage": "^0.1.1", "@nextcloud/dialogs": "^1.3.0", "@nextcloud/event-bus": "^1.1.4", "@nextcloud/initial-state": "^1.1.2", diff --git a/src/App.vue b/src/App.vue index 34c0db452..a88c0d53b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -44,6 +44,7 @@ import PreventUnload from 'vue-prevent-unload' import Router from './router/router' import RightSidebar from './components/RightSidebar/RightSidebar' import { EventBus } from './services/EventBus' +import BrowserStorage from './services/BrowserStorage' import { getCurrentUser } from '@nextcloud/auth' import { fetchConversation } from './services/conversationsService' import { @@ -311,9 +312,9 @@ export default { // see browserCheck mixin this.checkBrowser() // Check sidebar status in previous sessions - if (localStorage.getItem('sidebarOpen') === 'false') { + if (BrowserStorage.getItem('sidebarOpen') === 'false') { this.$store.dispatch('hideSidebar') - } else if (localStorage.getItem('sidebarOpen') === 'true') { + } else if (BrowserStorage.getItem('sidebarOpen') === 'true') { this.$store.dispatch('showSidebar') } }, diff --git a/src/components/RightSidebar/RightSidebar.vue b/src/components/RightSidebar/RightSidebar.vue index f3d0d4550..8a28b39ff 100644 --- a/src/components/RightSidebar/RightSidebar.vue +++ b/src/components/RightSidebar/RightSidebar.vue @@ -74,6 +74,7 @@ import AppSidebar from '@nextcloud/vue/dist/Components/AppSidebar' import AppSidebarTab from '@nextcloud/vue/dist/Components/AppSidebarTab' import ChatView from '../ChatView' import { CollectionList } from 'nextcloud-vue-collections' +import BrowserStorage from '../../services/BrowserStorage' import { CONVERSATION, WEBINAR, PARTICIPANT } from '../../constants' import ParticipantsTab from './Participants/ParticipantsTab' import { @@ -199,7 +200,7 @@ export default { handleClose() { this.dismissEditing() this.$store.dispatch('hideSidebar') - localStorage.setItem('sidebarOpen', 'false') + BrowserStorage.setItem('sidebarOpen', 'false') }, async onFavoriteChange() { diff --git a/src/components/TopBar/TopBar.vue b/src/components/TopBar/TopBar.vue index 443de7e8b..b2852f0ab 100644 --- a/src/components/TopBar/TopBar.vue +++ b/src/components/TopBar/TopBar.vue @@ -151,6 +151,7 @@ import Popover from '@nextcloud/vue/dist/Components/Popover' import Actions from '@nextcloud/vue/dist/Components/Actions' import CallButton from './CallButton' import { EventBus } from '../../services/EventBus' +import BrowserStorage from '../../services/BrowserStorage' import ActionCheckbox from '@nextcloud/vue/dist/Components/ActionCheckbox' import ActionInput from '@nextcloud/vue/dist/Components/ActionInput' import ActionLink from '@nextcloud/vue/dist/Components/ActionLink' @@ -366,7 +367,7 @@ export default { methods: { openSidebar() { this.$store.dispatch('showSidebar') - localStorage.setItem('sidebarOpen', 'true') + BrowserStorage.setItem('sidebarOpen', 'true') }, fullScreenChanged() { diff --git a/src/services/BrowserStorage.js b/src/services/BrowserStorage.js new file mode 100644 index 000000000..30abb2d5d --- /dev/null +++ b/src/services/BrowserStorage.js @@ -0,0 +1,23 @@ +/** + * @copyright Copyright (c) 2020 Joas Schilling + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +import { getBuilder } from '@nextcloud/browser-storage' + +export default getBuilder('talk').persist().build()