mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-04 21:58:54 -05:00
improvements
This commit is contained in:
@@ -125,8 +125,12 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
|
||||
|
||||
return ordered_structure
|
||||
},
|
||||
/**
|
||||
* flattened list of entries used for exporters
|
||||
* kinda uncool but works for now
|
||||
* @return {*[]}
|
||||
*/
|
||||
get_flat_entries: function () {
|
||||
//{amount: x.amount, unit: x.unit?.name ?? "", food: x.food?.name ?? ""}
|
||||
let items = []
|
||||
for (let i in this.get_entries_by_group) {
|
||||
for (let f in this.get_entries_by_group[i]['foods']) {
|
||||
@@ -435,6 +439,21 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
|
||||
this.deleteObject(this.entries[i])
|
||||
}
|
||||
},
|
||||
deleteShoppingListRecipe(shopping_list_recipe_id) {
|
||||
let api = new ApiApiFactory()
|
||||
|
||||
for (let i in this.entries) {
|
||||
if (this.entries[i].list_recipe === shopping_list_recipe_id) {
|
||||
Vue.delete(this.entries, i)
|
||||
}
|
||||
}
|
||||
|
||||
api.destroyShoppingListRecipe(shopping_list_recipe_id).then((x) => {
|
||||
// no need to update anything, entries were already removed
|
||||
}).catch((err) => {
|
||||
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_DELETE, err)
|
||||
})
|
||||
},
|
||||
/**
|
||||
* register the change to a set of entries to allow undoing it
|
||||
* throws an Error if the operation type is not known
|
||||
|
||||
@@ -95,10 +95,10 @@ export const useUserPreferenceStore = defineStore(_STORE_ID, {
|
||||
for (s in settings) {
|
||||
Vue.set(this.user_settings, s, settings[s])
|
||||
}
|
||||
//console.log(`loaded local user settings age ${((new Date().getTime()) - this.user_settings.locally_updated_at) / 1000} `)
|
||||
console.log(`loaded local user settings age ${((new Date().getTime()) - this.user_settings.locally_updated_at) / 1000} `)
|
||||
}
|
||||
if (((new Date().getTime()) - this.user_settings.locally_updated_at) > _STALE_TIME_IN_MS || !allow_cached_results) {
|
||||
//console.log('refreshing user settings from API')
|
||||
console.log('refreshing user settings from API')
|
||||
let apiClient = new ApiApiFactory()
|
||||
apiClient.retrieveUserPreference(localStorage.getItem('USER_ID')).then(r => {
|
||||
for (s in r.data) {
|
||||
|
||||
Reference in New Issue
Block a user