Added Tempstore Saving
This commit is contained in:
@@ -17,6 +17,10 @@ export const useAuthStore = defineStore("auth", {
|
||||
async init(token) {
|
||||
await this.fetchMe(token)
|
||||
|
||||
const tempStore = useTempStore()
|
||||
|
||||
if(this.profile.temp_config) tempStore.setStoredTempConfig(this.profile.temp_config)
|
||||
|
||||
if(useCapacitor().getIsNative()) {
|
||||
navigateTo("/mobile")
|
||||
} else {
|
||||
|
||||
@@ -3,33 +3,68 @@ import {defineStore} from 'pinia'
|
||||
// @ts-ignore
|
||||
export const useTempStore = defineStore('temp', () => {
|
||||
|
||||
const auth = useAuthStore()
|
||||
|
||||
const searchStrings = ref({})
|
||||
const filters = ref({})
|
||||
const columns = ref({})
|
||||
const pages = ref({})
|
||||
const settings = ref({})
|
||||
|
||||
const storeTempConfig = async () => {
|
||||
const config = {
|
||||
searchStrings: searchStrings.value,
|
||||
columns: columns.value,
|
||||
pages: pages.value,
|
||||
settings: settings.value,
|
||||
}
|
||||
|
||||
await useNuxtApp().$api(`/api/profiles/${auth.profile.id}`,{
|
||||
method: 'PUT',
|
||||
body: {temp_config: config}
|
||||
})
|
||||
}
|
||||
|
||||
function setStoredTempConfig (config) {
|
||||
searchStrings.value = config.searchStrings
|
||||
columns.value = config.columns
|
||||
pages.value = config.pages
|
||||
settings.value = config.settings
|
||||
}
|
||||
|
||||
function modifySearchString(type,input) {
|
||||
searchStrings.value[type] = input
|
||||
storeTempConfig()
|
||||
}
|
||||
|
||||
function clearSearchString(type) {
|
||||
searchStrings.value[type] = ""
|
||||
storeTempConfig()
|
||||
}
|
||||
|
||||
function modifyFilter(type,input) {
|
||||
filters.value[type] = input
|
||||
storeTempConfig()
|
||||
}
|
||||
|
||||
function modifyColumns(type,input) {
|
||||
columns.value[type] = input
|
||||
storeTempConfig()
|
||||
}
|
||||
|
||||
function modifyPages(type,input) {
|
||||
pages.value[type] = input
|
||||
storeTempConfig()
|
||||
}
|
||||
|
||||
function modifySettings(type,input) {
|
||||
settings.value[type] = input
|
||||
storeTempConfig()
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
setStoredTempConfig,
|
||||
searchStrings,
|
||||
modifySearchString,
|
||||
clearSearchString,
|
||||
@@ -38,7 +73,9 @@ export const useTempStore = defineStore('temp', () => {
|
||||
columns,
|
||||
modifyColumns,
|
||||
modifyPages,
|
||||
pages
|
||||
pages,
|
||||
modifySettings,
|
||||
settings
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user