mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-07 15:18:20 -05:00
space settings
This commit is contained in:
@@ -23,6 +23,7 @@ export enum ErrorMessageType {
|
||||
export enum PreparedMessage {
|
||||
UPDATE_SUCCESS = 'UPDATE_SUCCESS',
|
||||
CREATE_SUCCESS = 'CREATE_SUCCESS',
|
||||
DELETE_SUCCESS = 'DELETE_SUCCESS',
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,6 +94,7 @@ export const useMessageStore = defineStore('message_store', () => {
|
||||
if (preparedMessage == PreparedMessage.UPDATE_SUCCESS) {
|
||||
addMessage(MessageType.SUCCESS, 'Updated Successfully', 7000, {}) // TODO localize and make more useful ?
|
||||
addMessage(MessageType.SUCCESS, 'Created Successfully', 7000, {})
|
||||
addMessage(MessageType.SUCCESS, 'Deleted Successfully', 7000, {})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,10 +64,28 @@ export const useUserPreferenceStore = defineStore('user_preference_store', () =>
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* load data for currently active space
|
||||
*/
|
||||
function loadActiveSpace(){
|
||||
let api = new ApiApi()
|
||||
api.apiSpaceCurrentRetrieve().then(r => {
|
||||
activeSpace.value = r
|
||||
}).catch(err => {
|
||||
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* switch to the given space
|
||||
*/
|
||||
function switchSpace(space: Space){
|
||||
let api = new ApiApi()
|
||||
|
||||
api.apiSwitchActiveSpaceRetrieve({spaceId: space.id}).then(r => {
|
||||
loadActiveSpace()
|
||||
}).catch(err => {
|
||||
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -76,7 +94,7 @@ export const useUserPreferenceStore = defineStore('user_preference_store', () =>
|
||||
// always load active space on first initialization of store
|
||||
loadActiveSpace()
|
||||
|
||||
return {deviceSettings, userSettings, activeSpace, loadUserSettings, updateUserSettings}
|
||||
return {deviceSettings, userSettings, activeSpace, loadUserSettings, updateUserSettings, switchSpace}
|
||||
})
|
||||
|
||||
// enable hot reload for store
|
||||
|
||||
Reference in New Issue
Block a user