diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index 64ae15b..8f9b04e 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -17,21 +17,21 @@ @@ -56,7 +56,8 @@ export default defineComponent({ setup() { const store = useStore(), - visibleUIElements = computed(() => store.state.ui.visibleElements), + currentlyVisible = computed(() => store.state.ui.visibleElements), + previouslyVisible = computed(() => store.state.ui.previouslyVisibleElements), smallScreen = computed(() => store.state.ui.smallScreen), mapCount = computed(() => store.state.maps.size), following = computed(() => store.state.followTarget), @@ -68,12 +69,13 @@ export default defineComponent({ followActive = computed(() => { //Show following alongside playerlist on small screens return (!smallScreen.value && following) - || (smallScreen.value && visibleUIElements.value.has('players')); + || (smallScreen.value && currentlyVisible.value.has('players')); }); return { mapCount, - visibleUIElements, + currentlyVisible, + previouslyVisible, toggleElement, followActive, following, diff --git a/src/store/mutations.ts b/src/store/mutations.ts index 55cc404..40375c1 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -425,6 +425,7 @@ export const mutations: MutationTree & Mutations = { state.ui.visibleElements.clear(); } + state.ui.previouslyVisibleElements.add(element); newState ? state.ui.visibleElements.add(element) : state.ui.visibleElements.delete(element); }, @@ -433,6 +434,10 @@ export const mutations: MutationTree & Mutations = { state.ui.visibleElements.clear(); } + if(payload.state || state.ui.visibleElements.has(payload.element)) { + state.ui.previouslyVisibleElements.add(payload.element); + } + payload.state ? state.ui.visibleElements.add(payload.element) : state.ui.visibleElements.delete(payload.element); }, diff --git a/src/store/state.ts b/src/store/state.ts index 2ce3eac..c4ded74 100644 --- a/src/store/state.ts +++ b/src/store/state.ts @@ -61,6 +61,7 @@ export type State = { ui: { smallScreen: boolean; visibleElements: Set; + previouslyVisibleElements: Set; }; parsedUrl: DynmapParsedUrl; @@ -171,6 +172,7 @@ export const state: State = { ui: { smallScreen: false, visibleElements:new Set(), + previouslyVisibleElements: new Set(), }, parsedUrl: {