Web: store footer popover state in local storage

Keep the footer popover state in the local storage, restoring it on load:
- Visibility of the popover
- Current tab of the popover
This commit is contained in:
Sybren A. Stüvel 2022-05-20 14:43:30 +02:00
parent 6a8d959301
commit 4562e98df5
2 changed files with 12 additions and 3 deletions

@ -1,13 +1,18 @@
<script setup>
import { ref } from 'vue'
import { ref, watch } from 'vue'
import NotificationList from './NotificationList.vue'
import TaskLog from './TaskLog.vue'
import ConnectionStatus from '@/components/ConnectionStatus.vue'
const emit = defineEmits(['clickClose'])
const currentTab = ref('NotificationList')
const initialTab = localStorage.getItem("footer-popover-active-tab") || 'NotificationList';
const currentTab = ref(initialTab)
const tabs = { NotificationList, TaskLog }
watch(currentTab, async (newTab) => {
localStorage.setItem("footer-popover-active-tab", newTab);
});
</script>
<template>

@ -57,7 +57,7 @@ export default {
tasks: useTasks(),
notifs: useNotifs(),
taskLog: useTaskLog(),
showFooterPopup: false,
showFooterPopup: !!localStorage.getItem("footer-popover-visible"),
}),
computed: {
hasJobData() {
@ -85,6 +85,10 @@ export default {
this.taskLog.clear();
this._fetchTask(newTaskID);
},
showFooterPopup(shown) {
if (shown) localStorage.setItem("footer-popover-visible", "true");
else localStorage.removeItem("footer-popover-visible");
},
},
methods: {
onTableJobClicked(rowData) {