Skip to content

Commit

Permalink
localstore for chooseSmileyStayUnclosed
Browse files Browse the repository at this point in the history
  • Loading branch information
nkonev committed Jan 23, 2025
1 parent eb004f7 commit f87c4f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
10 changes: 8 additions & 2 deletions frontend/src/ChooseSmileyModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
color="primary"
hide-details
v-model="stayUnclosed"
@update:modelValue="changeStayUnclosed"
:label="$vuetify.locale.t('$vuetify.smiley_stay_unclosed')"
></v-checkbox>
<v-btn v-if="showSettings" color="primary" variant="flat" @click="closeSettings()" :title="$vuetify.locale.t('$vuetify.ok')">{{$vuetify.locale.t('$vuetify.ok')}}</v-btn>
Expand All @@ -50,8 +51,9 @@
</template>

<script>
import bus, {LOGGED_OUT, OPEN_MESSAGE_EDIT_SMILEY} from "./bus/bus";
import bus, {LOGGED_OUT, OPEN_MESSAGE_EDIT_SMILEY} from "./bus/bus";
import axios from "axios";
import {getChooseSmileyStayUnclosed, setChooseSmileyStayUnclosed} from "@/store/localStore.js";
const GROUP_SMILEYS = "smileys";
const GROUP_EMOJIS = "emojis";
Expand Down Expand Up @@ -101,6 +103,7 @@ import bus, {LOGGED_OUT, OPEN_MESSAGE_EDIT_SMILEY} from "./bus/bus";
},
methods: {
showModal({addSmileyCallback, title}) {
this.stayUnclosed = getChooseSmileyStayUnclosed();
this.$data.show = true;
this.addSmileyCallback = addSmileyCallback;
this.aTitle = title;
Expand Down Expand Up @@ -237,7 +240,10 @@ import bus, {LOGGED_OUT, OPEN_MESSAGE_EDIT_SMILEY} from "./bus/bus";
break
}
}
}
},
changeStayUnclosed(v) {
setChooseSmileyStayUnclosed(v)
},
},
mounted() {
bus.on(OPEN_MESSAGE_EDIT_SMILEY, this.showModal);
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/store/localStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,20 @@ export const getStoredFileListMode = () => {
export const setStoredFileListMode = (v) => {
localStorage.setItem(KEY_FILE_LIST_MODE, JSON.stringify(v));
}


export const KEY_CHOOSE_SMILEY_STAY_UNCLOSED = 'chooseSmileyStayUnclosed';

export const setChooseSmileyStayUnclosed = (v) => {
localStorage.setItem(KEY_CHOOSE_SMILEY_STAY_UNCLOSED, JSON.stringify(v));
}

export const getChooseSmileyStayUnclosed = () => {
let v = JSON.parse(localStorage.getItem(KEY_CHOOSE_SMILEY_STAY_UNCLOSED));
if (v === null) {
console.log("Resetting chooseSmileyStayUnclosed to default");
setChooseSmileyStayUnclosed(false);
v = JSON.parse(localStorage.getItem(KEY_CHOOSE_SMILEY_STAY_UNCLOSED));
}
return v;
}

0 comments on commit f87c4f2

Please sign in to comment.