enrecipes/app/store.ts

1264 lines
32 KiB
TypeScript
Raw Normal View History

2021-04-14 13:38:22 +00:00
import Vue from 'nativescript-vue'
2021-03-21 17:02:04 +00:00
import Vuex from 'vuex'
2021-06-15 11:04:42 +00:00
2021-03-21 17:02:04 +00:00
Vue.use(Vuex)
2021-06-15 11:04:42 +00:00
2021-05-22 08:56:31 +00:00
import {
getFileAccess,
File,
Application,
knownFolders,
path,
} from '@nativescript/core'
2021-06-05 18:08:36 +00:00
import {
getNumber,
setNumber,
getString,
setString,
} from '@nativescript/core/application-settings'
2021-06-15 11:04:42 +00:00
import { openOrCreate } from '@akylas/nativescript-sqlite'
2021-06-05 18:08:36 +00:00
import * as utils from '~/shared/utils'
2021-05-22 08:56:31 +00:00
2021-06-15 11:04:42 +00:00
// OpenDatabaseFile
2021-05-22 08:56:31 +00:00
const db = openOrCreate(
path.join(knownFolders.documents().path, 'EnRecipes.db')
)
2021-06-15 11:04:42 +00:00
// Create"recipes"Table
2021-05-22 08:56:31 +00:00
db.execute(
'CREATE TABLE IF NOT EXISTS recipes (id TEXT PRIMARY KEY, image TEXT, title TEXT, cuisine TEXT, category TEXT, tags TEXT, prepTime TEXT, cookTime TEXT, yieldQuantity TEXT, yieldUnit TEXT, difficulty TEXT, rating INT, ingredients TEXT, instructions TEXT, combinations TEXT, notes TEXT, favorite INT, tried INT, lastTried INT, lastModified INT, created INT)'
)
2021-06-15 11:04:42 +00:00
// Create"lists"Table
2021-05-22 08:56:31 +00:00
db.execute(
'CREATE TABLE IF NOT EXISTS lists (cuisines TEXT, categories TEXT, yieldUnits TEXT, units TEXT)'
)
2021-06-15 11:04:42 +00:00
// Create"mealPlans"Table
2021-05-22 08:56:31 +00:00
db.execute(
2021-06-15 11:04:42 +00:00
'CREATE TABLE IF NOT EXISTS mealPlans (id TEXT PRIMARY KEY, date INT, mealType TEXT, recipeID TEXT, quantity INT, note TEXT)'
2021-05-22 08:56:31 +00:00
)
2021-06-15 11:04:42 +00:00
// Create"timerPresets"Table
2021-06-05 18:08:36 +00:00
db.execute(
'CREATE TABLE IF NOT EXISTS timerPresets (id INT PRIMARY KEY, label TEXT, time TEXT)'
)
2021-06-15 11:04:42 +00:00
const defCuisines = [
2021-03-21 17:02:04 +00:00
'American',
'Brazilian',
'British',
'Chinese',
'Danish',
'Egyptian',
'Filipino',
'French',
'German',
'Greek',
'Indian',
'Irish',
'Italian',
'Jamaican',
'Japanese',
'Jewish',
'Kenyan',
'Korean',
'Mexican',
'Nigerian',
'Portuguese',
'Russian',
'Scottish',
'Spanish',
'Sri Lankan',
'Swedish',
'Thai',
'Turkish',
'Vietnamese',
]
2021-06-15 11:04:42 +00:00
const defCategories = [
2021-03-21 17:02:04 +00:00
'Appetizers',
'Barbecue',
'Beverages',
'Breads',
2021-04-15 16:44:21 +00:00
'breakfast',
2021-03-21 17:02:04 +00:00
'Desserts',
2021-04-15 16:44:21 +00:00
'dinner',
2021-03-21 17:02:04 +00:00
'Healthy',
2021-04-15 16:44:21 +00:00
'lunch',
2021-03-21 17:02:04 +00:00
'Main dishes',
'Meat',
'Noodles',
'Pasta',
'Poultry',
'Rice',
'Salads',
'Sauces',
'Seafood',
'Side dishes',
2021-04-15 16:44:21 +00:00
'snacks',
2021-03-21 17:02:04 +00:00
'Soups',
'Undefined',
'Vegan',
'Vegetarian',
]
2021-06-15 11:04:42 +00:00
const defYieldUnits = [
2021-03-21 17:02:04 +00:00
'Serving',
'Piece',
'Teaspoon',
'Tablespoon',
'Fluid Ounce',
'Ounce',
'Pound',
'Gram',
'Kilogram',
'Cup',
'Gallon',
'Millilitre',
'Litre',
'Roll',
'Patty',
'Loaf',
]
2021-06-15 11:04:42 +00:00
const defUnits = [
2021-03-21 17:02:04 +00:00
'unit',
'tsp',
'dsp',
'tbsp',
'fl oz',
'cup',
'pt',
'qt',
'gal',
'ml',
'l',
'oz',
'lb',
'mg',
'g',
'kg',
'cm',
'in',
'leaf',
'clove',
'piece',
'pinch',
'drop',
'dozen',
'stick',
'small',
'medium',
'large',
]
2021-06-05 18:08:36 +00:00
2020-12-29 10:35:19 +00:00
const listItems = {
cuisines: {
2021-06-05 18:08:36 +00:00
sort: 1,
2021-06-15 11:04:42 +00:00
defs: defCuisines,
2020-12-29 10:35:19 +00:00
},
categories: {
2021-06-05 18:08:36 +00:00
sort: 1,
2021-06-15 11:04:42 +00:00
defs: defCategories,
2020-12-29 10:35:19 +00:00
},
yieldUnits: {
2021-06-05 18:08:36 +00:00
sort: 0,
2021-06-15 11:04:42 +00:00
defs: defYieldUnits,
2020-12-29 10:35:19 +00:00
},
units: {
2021-06-05 18:08:36 +00:00
sort: 0,
2021-06-15 11:04:42 +00:00
defs: defUnits,
2021-03-21 17:02:04 +00:00
},
}
2021-04-01 10:55:35 +00:00
2021-06-18 16:22:03 +00:00
interface IRecipe {
id: string
image: string
title: string
cuisine: string
category: string
tags: string[]
prepTime: string
cookTime: string
yieldQuantity: number
yieldUnit: string
difficulty: string
rating: number
ingredients: string[]
instructions: string[]
combinations: string[]
notes: string[]
favorite: 0 | 1
tried: 0 | 1
lastTried: number | null
lastModified: number | null
created: number | null
}
interface IMealPlan {
id: string
date: number
mealType: string
recipeID: string
quantity: number
note: string
}
interface IMealPlanOld {
title: string
startDate: number
type: string
eventColor: string
}
2020-09-15 11:10:16 +00:00
export default new Vuex.Store({
state: {
2020-11-29 12:54:21 +00:00
recipes: [],
2020-12-29 10:35:19 +00:00
cuisines: [],
2020-10-26 20:49:54 +00:00
categories: [],
2020-11-02 11:36:53 +00:00
yieldUnits: [],
2020-12-29 10:35:19 +00:00
units: [],
2020-11-23 09:49:58 +00:00
mealPlans: [],
2020-10-14 19:32:32 +00:00
icon: {
2021-05-22 08:56:31 +00:00
cog: '\ue900',
home: '\ue901',
try: '\ue902',
tried: '\ue903',
fav: '\ue904',
faved: '\ue905',
menu: '\ue906',
2021-04-12 18:09:48 +00:00
cuisine: '\ue907',
2021-05-22 08:56:31 +00:00
category: '\ue908',
tag: '\ue909',
star: '\ue90a',
starred: '\ue90b',
time: '\ue90c',
diff: '\ue90d',
bag: '\ue90e',
bagged: '\ue90f',
price: '\ue910',
sear: '\ue911',
sort: '\ue912',
filter: '\ue913',
plus: '\ue914',
done: '\ue915',
back: '\ue916',
x: '\ue917',
del: '\ue918',
save: '\ue919',
undo: '\ue91a',
edit: '\ue91b',
cal: '\ue91c',
tod: '\ue91d',
left: '\ue91e',
right: '\ue91f',
img: '\ue920',
uncheck: '\ue921',
check: '\ue922',
share: '\ue923',
timer: '\ue924',
start: '\ue925',
pause: '\ue926',
addTo: '\ue927',
sound: '\ue928',
vibrate: '\ue929',
interface: '\ue92a',
opts: '\ue92b',
db: '\ue92c',
reset: '\ue92d',
info: '\ue92e',
lang: '\ue92f',
theme: '\ue930',
layout: '\ue931',
shuf: '\ue932',
week: '\ue933',
folder: '\ue934',
exp: '\ue935',
imp: '\ue936',
gh: '\ue937',
tg: '\ue938',
help: '\ue939',
priv: '\ue93a',
don: '\ue93b',
trans: '\ue93c',
delay: '\ue93d',
ring: '\ue93e',
2021-06-05 18:08:36 +00:00
print: '\ue93f',
2021-06-15 11:04:42 +00:00
dup: '\ue940',
calv: '\ue941',
mpd: '\ue942',
madd: '\ue943',
2021-06-18 12:52:03 +00:00
awake: '\ue944',
edge: '\ue945',
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
sortT: 'random', // SortType
langs: [
2021-06-05 18:08:36 +00:00
{
locale: 'ar',
title: 'العربية',
2021-06-15 11:04:42 +00:00
rtl: 1,
2021-06-05 18:08:36 +00:00
},
2021-04-23 14:30:50 +00:00
{
locale: 'da',
title: 'Dansk',
},
2021-03-21 17:02:04 +00:00
{
locale: 'de',
title: 'Deutsch',
},
2021-06-05 18:08:36 +00:00
{
locale: 'en-IN',
2021-06-18 12:52:03 +00:00
title: 'English (India)',
2021-06-05 18:08:36 +00:00
},
2021-03-21 17:02:04 +00:00
{
locale: 'en-GB',
2021-06-18 12:52:03 +00:00
title: 'English (United Kingdom)',
2021-03-21 17:02:04 +00:00
},
2021-06-05 18:08:36 +00:00
{
locale: 'en-US',
2021-06-18 12:52:03 +00:00
title: 'English (United States)',
2021-06-05 18:08:36 +00:00
},
2021-03-21 17:02:04 +00:00
{
locale: 'es',
title: 'Español',
},
{
locale: 'fr',
title: 'Français',
},
{
locale: 'fr-BE',
2021-06-18 12:52:03 +00:00
title: 'Français (Belgium)',
2021-03-21 17:02:04 +00:00
},
{
locale: 'fr-CA',
2021-06-18 12:52:03 +00:00
title: 'Français (Canada)',
2021-03-21 17:02:04 +00:00
},
{
locale: 'fr-CH',
2021-06-18 12:52:03 +00:00
title: 'Français (Switzerland)',
2021-03-21 17:02:04 +00:00
},
2021-04-17 16:24:47 +00:00
{
locale: 'hi',
title: 'हिंदी',
},
{
locale: 'id',
title: 'Indonesia',
},
2021-03-21 17:02:04 +00:00
{
locale: 'it',
title: 'Italiano',
},
2021-06-18 12:52:03 +00:00
{
locale: 'ja',
title: '日本語',
},
{
locale: 'ml',
title: 'മലയാളം',
},
2021-03-21 17:02:04 +00:00
{
locale: 'nb-NO',
title: 'Norsk bokmål',
},
{
locale: 'nl',
title: 'Nederlands',
},
2021-06-05 18:08:36 +00:00
{
locale: 'pt',
title: 'Português',
},
2021-04-23 14:30:50 +00:00
{
locale: 'pt-BR',
2021-06-18 12:52:03 +00:00
title: 'Português (Brazil)',
2021-04-23 14:30:50 +00:00
},
2021-03-21 17:02:04 +00:00
{
locale: 'ru',
title: 'Русский',
},
{
locale: 'ta',
title: 'தமிழ்',
},
2021-04-17 16:24:47 +00:00
{
locale: 'te',
title: 'తెలుగు',
},
2020-12-29 10:35:19 +00:00
],
2021-06-18 16:22:03 +00:00
shake: getNumber('shake', 1), // ShakeViewRandomRecipe
impSum: {
// ImportSummary
2020-12-29 10:35:19 +00:00
found: 0,
imported: 0,
2021-03-21 17:02:04 +00:00
updated: 0,
},
2021-06-05 18:08:36 +00:00
layout: getString('layout', 'detailed'),
2021-06-18 16:22:03 +00:00
selCuisine: null, // SelectedCuisine
selCategory: null, // SelectedCategory
selTag: null, // SelectedTag
2021-06-15 11:04:42 +00:00
theme: 'sysDef',
2021-06-18 16:22:03 +00:00
startMon: getNumber('startMon', 0), // StartWithMonday
timerD: getNumber('timerD', 1), // TimerDelay
timerS: {}, // TimerSound
timerV: getNumber('timerV', 0), // TimerVibrate
timerPs: [], // TimerPresets
activeTs: [], // ActiveTimers
FGS: 0, // ForeGroundService
2021-06-15 11:04:42 +00:00
RTL: getNumber('RTL', 0),
2021-06-18 16:22:03 +00:00
plannerV: getString('plannerV', 'wk'), // PlannerViewMode
planDel: getString('planDel', 'nvr'), // PlanDeletionCriteria
edgeS: getNumber('edgeS', 1), // EdgeSwipe
awakeV: getNumber('awakeV', 1), // AwakeViewer
2020-09-15 11:10:16 +00:00
},
mutations: {
2021-06-18 16:22:03 +00:00
// ToggleKeepAwakeOnRecipeViewer
toggleAwakeV(state) {
state.awakeV = +!state.awakeV
setNumber('awakeV', state.awakeV)
},
// ToggleEdgeSwipe
toggleEdgeS(state) {
state.edgeS = +!state.edgeS
setNumber('edgeS', state.edgeS)
},
// SetPlanDeletionCriteria
setPlanDel(state, s: string) {
state.planDel = s
setString('planDel', s)
},
// SetPlannerViewMode
setPlannerV(state, s: string) {
state.plannerV = s
setString('plannerV', s)
},
// SetRTLLayout
2021-06-05 18:08:36 +00:00
setRTL(state) {
2021-06-15 11:04:42 +00:00
state.RTL = getNumber('RTL', 0)
2021-06-05 18:08:36 +00:00
},
2021-06-18 16:22:03 +00:00
// SetForegroundService
setFgS(state, n: number) {
state.FGS = n
2021-06-05 18:08:36 +00:00
},
2021-06-18 16:22:03 +00:00
// AddTimerPreset
addTP(state, o) {
let i = state.timerPs.findIndex((e) => e.id == o.id)
if (state.timerPs.some((e) => e.id == o.id)) {
state.timerPs.splice(i, 1, o)
} else state.timerPs.push(o)
2021-06-05 18:08:36 +00:00
db.execute(
`REPLACE INTO timerPresets (id, label, time) VALUES (?, ?, ?)`,
2021-06-18 16:22:03 +00:00
[o.id, o.label, o.time]
2021-06-05 18:08:36 +00:00
)
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
// DeleteTimerPreset
deleteTP(state, n: number) {
let id = state.timerPs[n]
state.timerPs.splice(n, 1)
2021-06-05 18:08:36 +00:00
db.execute(`DELETE FROM timerPresets WHERE id = ${id}`)
},
2021-06-18 16:22:03 +00:00
// InitialiseTimerPreset
initTPs(state) {
if (!state.timerPs.length)
2021-06-05 18:08:36 +00:00
db.select(`SELECT * FROM timerPresets`).then((res) => {
res.forEach((t) => {
t.recipeID = 0
t.timerInt = 0
t.isPaused = 0
t.preset = 1
t.done = 0
2021-06-18 16:22:03 +00:00
state.timerPs.push(t)
2021-06-05 18:08:36 +00:00
})
})
},
2021-06-18 16:22:03 +00:00
// ImportTimerPresets
importTPs(state, ao) {
let newPresets = ao.filter(
(e) => !state.timerPs.some((f) => f.id === e.id)
2021-06-05 18:08:36 +00:00
)
newPresets.forEach((t) => {
db.execute(
`INSERT INTO timerPresets (id, label, time) VALUES (?, ?, ?)`,
[t.id, t.label, t.time]
)
2021-06-18 16:22:03 +00:00
state.timerPs.push(t)
2021-06-05 18:08:36 +00:00
})
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
// ClearActiveTimerInterval
clearATIs(state) {
state.activeTs.forEach((e) => {
2021-06-05 18:08:36 +00:00
clearInterval(e.timerInt)
e.timerInt = 0
2021-05-22 08:56:31 +00:00
})
},
2021-06-18 16:22:03 +00:00
// AddActiveTimer
addAT(state, { timer, i }) {
state.activeTs.splice(i, 0, timer)
2021-06-05 18:08:36 +00:00
},
2021-06-18 16:22:03 +00:00
// SortActiveTimers
sortATs(state) {
let a = state.activeTs.reduce((acc, e) => {
2021-06-05 18:08:36 +00:00
;(acc[e.recipeID] = acc[e.recipeID] || []).push(e)
return acc
}, {})
2021-06-18 16:22:03 +00:00
state.activeTs = [...(<any>Object).values(a).flat(2)]
},
// UpdateActiveTimer
updateAT(state, o) {
let i = state.activeTs.findIndex((e) => e.id == o.id)
state.activeTs.splice(i, 1, o)
},
// RemoveActiveTimer
removeAT(state, n: number) {
state.activeTs.splice(n, 1)
},
// SetTimerDelay
setTD(state, n: number) {
state.timerD = n
setNumber('timerD', n)
},
// SetTimerSound
setTS(state, s: string) {
state.timerS = s
setString('timerS', JSON.stringify(s))
},
// SetTimerVibrate
setTV(state, n: number) {
state.timerV = n
setNumber('timerV', n)
},
// ClearImportSummary
clearIS(state) {
for (const key in state.impSum) state.impSum[key] = 0
},
// SetFirstDayMonday
setFD(state, n: number) {
state.startMon = n
setNumber('startMon', n)
},
// SetTheme
setT(state, s: string) {
switch (s) {
2021-04-23 19:50:32 +00:00
case 'sysDef':
2021-06-15 11:04:42 +00:00
state.theme =
2021-05-22 08:56:31 +00:00
Application.systemAppearance() == 'dark' ? 'Dark' : 'Light'
break
2021-04-23 19:50:32 +00:00
case 'sysDefB':
2021-06-15 11:04:42 +00:00
state.theme =
2021-05-22 08:56:31 +00:00
Application.systemAppearance() == 'dark' ? 'Black' : 'Light'
break
2021-04-23 19:50:32 +00:00
default:
2021-06-18 16:22:03 +00:00
state.theme = s
2021-05-22 08:56:31 +00:00
break
2021-04-23 19:50:32 +00:00
}
2021-06-18 16:22:03 +00:00
setString('theme', s)
2021-04-01 10:55:35 +00:00
},
2021-06-18 16:22:03 +00:00
// ClearFilter
clearF(state) {
2021-06-15 11:04:42 +00:00
state.selCuisine = state.selCategory = state.selTag = null
2021-04-01 10:55:35 +00:00
},
2021-06-18 16:22:03 +00:00
// SetLayout
setL(state, s: string) {
state.layout = s
setString('layout', s)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
// SetSortType
setST(state, s: string) {
state.sortT = s
2020-10-26 20:49:54 +00:00
},
2021-06-18 16:22:03 +00:00
// InitialiseRecipes
initRs(state) {
2021-06-15 11:04:42 +00:00
if (!state.recipes.length) {
db.select('SELECT * FROM recipes').then((res) => {
res.forEach((e) => {
Object.keys(e).forEach(
(f) =>
f.match(/tags|ingredients|instructions|combinations|notes/) &&
(e[f] = JSON.parse(e[f]))
)
state.recipes.push(e)
})
2021-05-22 08:56:31 +00:00
})
2021-06-15 11:04:42 +00:00
}
state.shake = getNumber('shake', 1)
2021-06-18 16:22:03 +00:00
state.sortT = getString('sortT', 'random')
2020-11-06 09:07:41 +00:00
},
2021-06-18 16:22:03 +00:00
// ImportRecipesFromJSON
importRsJSON(state, ao) {
2021-03-21 17:02:04 +00:00
let localRecipesIDs, partition
2020-12-29 10:35:19 +00:00
let imported = 0
let updated = 0
function getUpdatedData(data) {
2021-03-21 17:02:04 +00:00
return data.map((recipe) => {
let r = Object.assign({}, recipe)
if (r.timeRequired) {
2021-03-21 17:02:04 +00:00
r.prepTime = '00:00'
r.cookTime = r.timeRequired
delete r.timeRequired
}
2021-05-22 08:56:31 +00:00
if (r.imageSrc) {
r.image = r.imageSrc.replace('enrecipes', 'EnRecipes')
delete r.imageSrc
}
2021-03-21 17:02:04 +00:00
if (!r.hasOwnProperty('cuisine')) r.cuisine = 'Undefined'
if (!r.hasOwnProperty('tags')) r.tags = []
if (!r.hasOwnProperty('difficulty')) r.difficulty = 'Easy'
if (!r.hasOwnProperty('rating')) r.rating = 0
if (!r.hasOwnProperty('created')) r.created = r.lastModified
2021-05-22 08:56:31 +00:00
r.yieldQuantity = r.yield.quantity
r.yieldUnit = r.yield.unit
delete r.yield
2021-06-05 18:08:36 +00:00
function getTime(d) {
return new Date(d).getTime()
}
r.lastTried = getTime(r.lastTried)
r.lastModified = getTime(r.lastModified)
r.created = getTime(r.created)
2021-06-15 11:04:42 +00:00
r.favorite = r.favorite | 0
r.tried = r.tried | 0
2021-03-21 17:02:04 +00:00
return r
})
}
2020-11-06 09:07:41 +00:00
function createDocuments(data) {
2021-03-21 17:02:04 +00:00
data = getUpdatedData(data)
state.recipes = [...state.recipes, ...data]
2021-05-22 08:56:31 +00:00
data.forEach((r) => {
2020-12-29 10:35:19 +00:00
imported++
2021-05-22 08:56:31 +00:00
db.execute(
`INSERT INTO recipes (id, image, title, cuisine, category, tags, prepTime, cookTime, yieldQuantity, yieldUnit, difficulty, rating, ingredients, instructions, combinations, notes, favorite, tried, lastTried, lastModified, created) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
[
r.id,
r.image,
r.title,
r.cuisine,
r.category,
JSON.stringify(r.tags),
r.prepTime,
r.cookTime,
r.yieldQuantity,
r.yieldUnit,
r.difficulty,
r.rating,
JSON.stringify(r.ingredients),
JSON.stringify(r.instructions),
JSON.stringify(r.combinations),
JSON.stringify(r.notes),
2021-06-15 11:04:42 +00:00
r.favorite,
r.tried,
2021-06-05 18:08:36 +00:00
r.lastTried,
r.lastModified,
r.created,
2021-05-22 08:56:31 +00:00
]
)
2021-03-21 17:02:04 +00:00
})
2020-11-06 09:07:41 +00:00
}
function updateDocuments(data) {
2021-03-21 17:02:04 +00:00
data = getUpdatedData(data)
2021-05-22 08:56:31 +00:00
data.forEach((r) => {
2021-03-21 17:02:04 +00:00
let recipeIndex = state.recipes
.map((e, i) => {
let d1 = new Date(e.lastModified).getTime()
2021-05-22 08:56:31 +00:00
let d2 = new Date(r.lastModified).getTime()
return e.id === r.id && d1 < d2 ? i : -1
2021-03-21 17:02:04 +00:00
})
.filter((e) => e >= 0)[0]
2020-11-23 09:49:58 +00:00
if (recipeIndex >= 0) {
2020-12-29 10:35:19 +00:00
updated++
2021-05-22 08:56:31 +00:00
Object.assign(state.recipes[recipeIndex], r)
db.execute(
`REPLACE INTO recipes (id, image, title, cuisine, category, tags, prepTime, cookTime, yieldQuantity, yieldUnit, difficulty, rating, ingredients, instructions, combinations, notes, favorite, tried, lastTried, lastModified, created) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
[
r.id,
r.image,
r.title,
r.cuisine,
r.category,
JSON.stringify(r.tags),
r.prepTime,
r.cookTime,
r.yieldQuantity,
r.yieldUnit,
r.difficulty,
r.rating,
JSON.stringify(r.ingredients),
JSON.stringify(r.instructions),
JSON.stringify(r.combinations),
JSON.stringify(r.notes),
2021-06-15 11:04:42 +00:00
r.favorite,
r.tried,
2021-06-05 18:08:36 +00:00
r.lastTried,
r.lastModified,
r.created,
2021-05-22 08:56:31 +00:00
]
)
2020-11-23 09:49:58 +00:00
}
2021-03-21 17:02:04 +00:00
})
2020-11-02 11:36:53 +00:00
}
2020-12-29 10:35:19 +00:00
if (state.recipes.length) {
2021-03-21 17:02:04 +00:00
localRecipesIDs = state.recipes.map((e) => e.id)
2021-06-18 16:22:03 +00:00
partition = ao.reduce(
2021-05-22 08:56:31 +00:00
(result, recipe) => {
2021-03-21 17:02:04 +00:00
localRecipesIDs.indexOf(recipe.id) < 0
? result[0].push(recipe) // create candidates
: result[1].push(recipe) // update candidates
return result
},
[[], []]
)
if (partition[0].length) createDocuments(partition[0])
if (partition[1].length) updateDocuments(partition[1])
} else {
2021-06-18 16:22:03 +00:00
createDocuments(ao)
2020-10-26 20:49:54 +00:00
}
2021-06-18 16:22:03 +00:00
state.impSum.found = ao.length
state.impSum.imported = imported
state.impSum.updated = updated
2020-12-29 10:35:19 +00:00
},
2021-06-18 16:22:03 +00:00
// ImportRecipesFromDB
importRsDB(state, ao) {
2021-05-22 08:56:31 +00:00
let localRecipesIDs: string[], partition: any[]
let imported = 0
let updated = 0
function createDocuments(data: any[]) {
data.forEach((r) => {
const cols = Object.keys(r).join(', ')
const placeholder = Object.keys(r)
.fill('?')
.join(', ')
imported++
db.execute(
`REPLACE INTO recipes (${cols}) VALUES (${placeholder})`,
Object.values(r)
)
Object.keys(r).forEach(
(f) =>
f.match(/tags|ingredients|instructions|combinations|notes/) &&
(r[f] = JSON.parse(r[f]))
)
state.recipes.push(r)
})
}
function updateDocuments(data: any[]) {
data.forEach((r) => {
let recipeIndex = state.recipes
.map((e, i) => {
let d1 = new Date(e.lastModified).getTime()
let d2 = new Date(r.lastModified).getTime()
return e.id === r.id && d1 < d2 ? i : -1
})
.filter((e) => e >= 0)[0]
if (recipeIndex >= 0) {
updated++
const cols = Object.keys(r).join(', ')
const placeholder = Object.keys(r)
.fill('?')
.join(', ')
db.execute(
`REPLACE INTO recipes (${cols}) VALUES (${placeholder})`,
Object.values(r)
)
Object.keys(r).forEach(
(f) =>
f.match(/tags|ingredients|instructions|combinations|notes/) &&
(r[f] = JSON.parse(r[f]))
)
Object.assign(state.recipes[recipeIndex], r)
}
})
}
if (state.recipes.length) {
localRecipesIDs = state.recipes.map((e) => e.id)
2021-06-18 16:22:03 +00:00
partition = ao.reduce(
2021-05-22 08:56:31 +00:00
(result, recipe) => {
localRecipesIDs.indexOf(recipe.id) < 0
? result[0].push(recipe) // create candidates
: result[1].push(recipe) // update candidates
return result
},
[[], []]
)
if (partition[0].length) createDocuments(partition[0])
if (partition[1].length) updateDocuments(partition[1])
2021-06-18 16:22:03 +00:00
} else createDocuments(ao)
state.impSum.found = ao.length
state.impSum.imported = imported
state.impSum.updated = updated
},
// AddRecipe
addR(state, o: IRecipe) {
let r = JSON.parse(JSON.stringify(o))
Object.keys(o).forEach((e) => {
2021-05-22 08:56:31 +00:00
if (e.match(/tags|ingredients|instructions|combinations|notes/))
r[e] = JSON.stringify(r[e])
if (e.match(/favorite|tried/)) r[e] = r[e] ? 1 : 0
})
2021-06-18 16:22:03 +00:00
const cols = Object.keys(o).join(', ')
const placeholder = Object.keys(o)
2021-05-22 08:56:31 +00:00
.fill('?')
.join(', ')
db.execute(
`REPLACE INTO recipes (${cols}) VALUES (${placeholder})`,
Object.values(r)
2021-03-21 17:02:04 +00:00
)
2021-05-22 08:56:31 +00:00
let i: number
function exist({ id }, index: number) {
2021-06-18 16:22:03 +00:00
if (id === o.id) {
2021-05-22 08:56:31 +00:00
i = index
2021-06-05 18:08:36 +00:00
return 1
2020-11-15 10:51:10 +00:00
}
2021-06-05 18:08:36 +00:00
return 0
2021-05-22 08:56:31 +00:00
}
state.recipes.some(exist)
2021-06-18 16:22:03 +00:00
? Object.assign(state.recipes[i], o)
: state.recipes.push(o)
2020-12-29 10:35:19 +00:00
},
2021-06-18 16:22:03 +00:00
// DeleteRecipes
deleteRs(state, a) {
a.forEach((id: string) => {
2021-06-05 18:08:36 +00:00
let i = state.recipes.findIndex((e) => e.id === id)
getFileAccess().deleteFile(state.recipes[i].image)
state.recipes.splice(i, 1)
2021-05-22 08:56:31 +00:00
db.execute(`DELETE FROM recipes WHERE id = '${id}'`)
2021-01-23 17:20:15 +00:00
state.recipes.forEach((e, i) => {
if (e.combinations.includes(id)) {
2021-03-21 17:02:04 +00:00
state.recipes[i].combinations.splice(e.combinations.indexOf(id), 1)
2021-05-22 08:56:31 +00:00
db.execute(
`UPDATE recipes SET combinations = '${JSON.stringify(
state.recipes[i].combinations
)}' WHERE id = '${id}'`
)
2021-01-23 17:20:15 +00:00
}
2021-03-21 17:02:04 +00:00
})
})
2021-01-23 17:20:15 +00:00
},
2021-06-18 16:22:03 +00:00
// InitialiseListItems
initLIs(state) {
2021-05-22 08:56:31 +00:00
if (!state.cuisines.length) {
db.select(`SELECT * FROM lists`).then((res) => {
if (!res.length) {
db.execute(
`INSERT INTO lists (cuisines, categories, yieldUnits, units) VALUES (?, ?, ?, ?)`,
[null, null, null, null]
2021-03-21 17:02:04 +00:00
)
2020-12-29 10:35:19 +00:00
}
2021-05-22 08:56:31 +00:00
db.select(`SELECT * FROM lists`).then((res) => {
Object.keys(res[0]).forEach((list) => {
let userItems: string[]
2021-06-15 11:04:42 +00:00
let defs = listItems[list].defs
2021-05-22 08:56:31 +00:00
if (res[0][list]) {
userItems = JSON.parse(res[0][list])
2021-06-15 11:04:42 +00:00
state[list] = userItems.some((e: string) => defs.includes(e))
2021-05-22 08:56:31 +00:00
? userItems
2021-06-15 11:04:42 +00:00
: [...defs, ...userItems]
2021-05-22 08:56:31 +00:00
} else {
2021-06-15 11:04:42 +00:00
state[list] = defs
2021-05-22 08:56:31 +00:00
listItems[list].sort && state[list].sort()
}
})
})
})
2021-03-21 17:02:04 +00:00
}
},
2021-06-18 16:22:03 +00:00
// ImportListItems
importLIs(state, { data, listName }) {
2021-05-22 08:56:31 +00:00
state[listName] = [...new Set([...state[listName], ...data])]
if (listItems[listName].sort) state[listName].sort()
db.execute(
`UPDATE lists SET ${listName} = '${JSON.stringify(state[listName])}'`
)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
// AddListItem
addLI(state, { item, listName }) {
2021-05-22 08:56:31 +00:00
let lowercase = state[listName].map((e: string) => e.toLowerCase())
2020-12-29 10:35:19 +00:00
if (lowercase.indexOf(item.toLowerCase()) == -1) {
2021-05-22 08:56:31 +00:00
state[listName].push(item)
2020-12-29 10:35:19 +00:00
if (listItems[listName].sort)
2021-05-22 08:56:31 +00:00
state[listName].sort((a: string, b: string) =>
2021-03-21 17:02:04 +00:00
a.toLowerCase().localeCompare(b.toLowerCase())
)
2021-05-22 08:56:31 +00:00
db.execute(
`UPDATE lists SET ${listName} = '${JSON.stringify(state[listName])}'`
)
2021-01-23 17:40:30 +00:00
}
},
2021-06-18 16:22:03 +00:00
// RemoveListItem
removeLI(state, { item, listName }) {
2021-05-22 08:56:31 +00:00
state[listName].splice(state[listName].indexOf(item), 1)
db.execute(
`UPDATE lists SET ${listName} = '${JSON.stringify(state[listName])}'`
)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
// ResetListItems
resetLIs(state, listName) {
2021-06-15 11:04:42 +00:00
let defs = listItems[listName].defs
state[listName] = [...defs]
2021-05-22 08:56:31 +00:00
if (listItems[listName].sort)
state[listName].sort((a: string, b: string) =>
a.toLowerCase().localeCompare(b.toLowerCase())
)
db.execute(
`UPDATE lists SET ${listName} = '${JSON.stringify(state[listName])}'`
)
2020-10-26 20:49:54 +00:00
},
2021-06-18 16:22:03 +00:00
// InitialiseMealPlans
initMPs(state) {
2021-06-15 11:04:42 +00:00
if (!state.mealPlans.length) {
2021-06-18 16:22:03 +00:00
let c = state.planDel
2021-06-15 11:04:42 +00:00
let date = new Date()
let d = new Date()
2021-06-18 12:52:03 +00:00
d.setHours(0, 0, 0, 0)
let ld =
c == 'otay'
? 365
: c == 'otam'
? new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate()
: 7
d.setDate(d.getDate() - ld)
2021-06-15 11:04:42 +00:00
2021-05-22 08:56:31 +00:00
db.select(`SELECT * FROM mealPlans`).then((res) =>
2021-06-18 12:52:03 +00:00
res.forEach((p: any) =>
c !== 'nvr' && p.date < d.getTime()
? db.execute(`DELETE FROM mealPlans WHERE id = '${p.id}'`)
: state.mealPlans.push(p)
)
2021-03-21 17:02:04 +00:00
)
2021-06-15 11:04:42 +00:00
}
2020-11-23 09:49:58 +00:00
},
2021-06-18 16:22:03 +00:00
// ImportMealPlansFromJSON
importMPsJSON(state, ao) {
2021-06-15 11:04:42 +00:00
let updatedMealPlans = []
2021-06-18 16:22:03 +00:00
let newMealPlans = ao.filter((e) => {
2021-03-21 17:02:04 +00:00
if (e.hasOwnProperty('eventColor')) {
return !state.mealPlans.some((f) => {
2021-01-23 17:20:15 +00:00
let d = new Date(e.startDate)
2021-03-21 17:02:04 +00:00
let date = new Date(
d.getFullYear(),
d.getMonth(),
d.getDate(),
0
).getTime()
2021-01-23 17:20:15 +00:00
let type
switch (d.getHours()) {
case 0:
2021-03-21 17:02:04 +00:00
type = 'breakfast'
break
2021-01-23 17:20:15 +00:00
case 5:
2021-03-21 17:02:04 +00:00
type = 'lunch'
break
2021-01-23 17:20:15 +00:00
case 10:
2021-03-21 17:02:04 +00:00
type = 'dinner'
break
2021-01-23 17:20:15 +00:00
case 15:
2021-03-21 17:02:04 +00:00
type = 'snacks'
break
2021-01-23 17:20:15 +00:00
}
2021-06-15 11:04:42 +00:00
return f.recipeID == e.title && f.date == date && f.mealType == type
2021-01-23 17:20:15 +00:00
})
} else {
2021-03-21 17:02:04 +00:00
return !state.mealPlans.some(
2021-06-15 11:04:42 +00:00
(f) =>
f.recipeID == e.title && f.date == e.date && f.mealType == e.type
2021-03-21 17:02:04 +00:00
)
2021-01-23 17:20:15 +00:00
}
})
2021-06-15 11:04:42 +00:00
newMealPlans.forEach((p) => {
p.id = utils.getRandomID()
p.recipeID = p.title
p.quantity = 1
p.note = null
if (p.hasOwnProperty('eventColor')) {
2021-01-23 17:20:15 +00:00
let d = new Date(p.startDate)
2021-03-21 17:02:04 +00:00
p.date = new Date(
d.getFullYear(),
d.getMonth(),
d.getDate(),
0
).getTime()
2021-01-23 17:20:15 +00:00
switch (d.getHours()) {
case 0:
2021-06-15 11:04:42 +00:00
p.mealType = 'breakfast'
2021-03-21 17:02:04 +00:00
break
2021-01-23 17:20:15 +00:00
case 5:
2021-06-15 11:04:42 +00:00
p.mealType = 'lunch'
2021-03-21 17:02:04 +00:00
break
2021-01-23 17:20:15 +00:00
case 10:
2021-06-15 11:04:42 +00:00
p.mealType = 'dinner'
2021-03-21 17:02:04 +00:00
break
2021-01-23 17:20:15 +00:00
case 15:
2021-06-15 11:04:42 +00:00
p.mealType = 'snacks'
2021-03-21 17:02:04 +00:00
break
2021-01-23 17:20:15 +00:00
}
2021-06-15 11:04:42 +00:00
delete p.title
2021-01-23 17:20:15 +00:00
delete p.startDate
delete p.endDate
delete p.eventColor
2021-06-15 11:04:42 +00:00
} else {
p.mealType = p.type
delete p.type
delete p.title
}
updatedMealPlans.push(p)
})
2021-03-21 17:02:04 +00:00
state.mealPlans = [...state.mealPlans, ...updatedMealPlans]
2021-06-15 11:04:42 +00:00
updatedMealPlans.forEach((p) => {
2021-05-22 08:56:31 +00:00
db.execute(
2021-06-15 11:04:42 +00:00
`INSERT INTO mealPlans (id, date, mealType, recipeID, quantity, note) VALUES (?, ?, ?, ?, ?, ?)`,
[p.id, p.date, p.mealType, p.recipeID, p.quantity, p.note]
2021-05-22 08:56:31 +00:00
)
})
2020-12-29 10:35:19 +00:00
},
2021-06-18 16:22:03 +00:00
// ImportMealPlansFromDB
importMPsDB(state, ao: IMealPlan[]) {
let newMealPlans = ao.filter(
2021-05-22 08:56:31 +00:00
(e) =>
!state.mealPlans.some((f) =>
Object.keys(f).every((key) => f[key] == e[key])
)
)
state.mealPlans = [...state.mealPlans, ...newMealPlans]
2021-06-15 11:04:42 +00:00
newMealPlans.forEach((p) => {
2021-05-22 08:56:31 +00:00
db.execute(
2021-06-15 11:04:42 +00:00
`INSERT INTO mealPlans (id, date, mealType, recipeID, quantity, note) VALUES (?, ?, ?, ?, ?, ?)`,
[p.id, p.date, p.mealType, p.recipeID, p.quantity, p.note]
2021-05-22 08:56:31 +00:00
)
})
},
2021-06-18 16:22:03 +00:00
// AddMealPlan
addMP(
state,
{ plan, index, inDB }: { plan: IMealPlan; index: number; inDB: number }
) {
2021-01-13 05:02:48 +00:00
let mealPlan = {
2021-06-15 11:04:42 +00:00
id: plan.id,
date: plan.date,
mealType: plan.mealType,
recipeID: plan.recipeID,
quantity: plan.quantity,
note: plan.note,
2021-01-13 05:02:48 +00:00
}
2021-06-05 18:08:36 +00:00
if (inDB) {
const cols = Object.keys(mealPlan).join(', ')
const placeholder = Object.keys(mealPlan)
.fill('?')
.join(', ')
db.execute(
2021-06-15 11:04:42 +00:00
`REPLACE INTO mealPlans (${cols}) VALUES (${placeholder})`,
2021-06-05 18:08:36 +00:00
Object.values(mealPlan)
)
if (index === null) state.mealPlans.push(mealPlan)
} else {
state.mealPlans.splice(index, 0, mealPlan)
}
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
// DeleteMealPlan
deleteMP(
state,
{ id, index, inDB }: { id: string; index: number; inDB: number }
) {
2021-06-05 18:08:36 +00:00
if (inDB) {
2021-06-15 11:04:42 +00:00
db.execute(`DELETE FROM mealPlans WHERE id = '${id}'`)
2021-06-05 18:08:36 +00:00
} else {
state.mealPlans.splice(index, 1)
state.mealPlans = [...state.mealPlans]
}
2021-03-21 17:02:04 +00:00
},
2021-05-22 08:56:31 +00:00
toggleState(state, { id, key, setDate }) {
2021-06-05 18:08:36 +00:00
let i = state.recipes.findIndex((e) => e.id == id)
state.recipes[i][key] = state.recipes[i][key] ? 0 : 1
2021-05-22 08:56:31 +00:00
db.execute(
2021-06-05 18:08:36 +00:00
`UPDATE recipes SET ${key} = ${state.recipes[i][key]} WHERE id = '${id}'`
2021-03-21 17:02:04 +00:00
)
2021-05-22 08:56:31 +00:00
if (setDate) {
2021-06-05 18:08:36 +00:00
state.recipes[i].lastTried = new Date().getTime()
2021-05-22 08:56:31 +00:00
db.execute(
2021-06-05 18:08:36 +00:00
`UPDATE recipes SET lastTried = ${state.recipes[i].lastTried} WHERE id = '${id}'`
2021-05-22 08:56:31 +00:00
)
}
2020-10-26 20:49:54 +00:00
},
2021-06-18 16:22:03 +00:00
// UnLinkCombinations
unLinkCs(state, { id, a }) {
2020-11-15 10:51:10 +00:00
state.recipes.forEach((e, i) => {
2021-06-18 16:22:03 +00:00
if (a.includes(e.id)) {
2021-03-21 17:02:04 +00:00
state.recipes[i].combinations.splice(e.combinations.indexOf(id), 1)
2021-05-22 08:56:31 +00:00
db.execute(
`UPDATE recipes SET combinations = '${JSON.stringify(
state.recipes[i].combinations
)}' WHERE id = '${id}'`
)
2020-12-29 10:35:19 +00:00
}
2021-03-21 17:02:04 +00:00
})
2020-12-29 10:35:19 +00:00
},
2021-06-18 16:22:03 +00:00
// SetShake
setS(state, n: number) {
2021-06-15 11:04:42 +00:00
state.shake = n
setNumber('shake', n)
2020-12-29 10:35:19 +00:00
},
2021-06-18 16:22:03 +00:00
// SetRating
setR(state, { id, rating }) {
2021-06-05 18:08:36 +00:00
let i = state.recipes.findIndex((e) => e.id == id)
state.recipes[i].rating = rating
2021-05-22 08:56:31 +00:00
db.execute(`UPDATE recipes SET rating = ${rating} WHERE id = '${id}'`)
2020-12-29 10:35:19 +00:00
},
2021-06-18 16:22:03 +00:00
// UnLinkBrokenImages
unLinkBIs(state) {
2020-12-29 10:35:19 +00:00
state.recipes.forEach((r, i) => {
2021-05-22 08:56:31 +00:00
if (r.image && !File.exists(r.image)) {
r.image = null
2021-03-21 17:02:04 +00:00
Object.assign(state.recipes[i], r)
2021-05-22 08:56:31 +00:00
db.execute(`UPDATE recipes SET image = null WHERE id = '${r.id}'`)
2020-11-15 10:51:10 +00:00
}
})
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
setCuisine(state, s: string) {
state.selCuisine = s
2021-04-01 10:55:35 +00:00
},
2021-06-18 16:22:03 +00:00
setCategory(state, s: string) {
state.selCategory = s
2021-04-01 10:55:35 +00:00
},
2021-06-18 16:22:03 +00:00
setTag(state, s: string) {
state.selTag = s
2021-04-01 10:55:35 +00:00
},
2020-09-15 11:10:16 +00:00
},
actions: {
2021-06-18 16:22:03 +00:00
toggleAwakeV({ commit }) {
commit('toggleAwakeV')
2021-06-18 12:52:03 +00:00
},
2021-06-18 16:22:03 +00:00
toggleEdgeS({ commit }) {
commit('toggleEdgeS')
2021-06-18 12:52:03 +00:00
},
2021-06-18 16:22:03 +00:00
setPlanDel({ commit }, s: string) {
commit('setPlanDel', s)
2021-06-15 11:04:42 +00:00
},
2021-06-18 16:22:03 +00:00
setPlannerV({ commit }, s: string) {
commit('setPlannerV', s)
2021-06-15 11:04:42 +00:00
},
2021-06-05 18:08:36 +00:00
setRTL({ commit }) {
commit('setRTL')
},
2021-06-18 16:22:03 +00:00
sortATs({ commit }) {
commit('sortATs')
2021-06-05 18:08:36 +00:00
},
2021-06-18 16:22:03 +00:00
setFgS({ commit }, n: number) {
commit('setFgS', n)
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
addTP({ commit }, o) {
commit('addTP', o)
2021-06-05 18:08:36 +00:00
},
2021-06-18 16:22:03 +00:00
deleteTP({ commit }, o) {
commit('deleteTP', o)
2021-06-05 18:08:36 +00:00
},
2021-06-18 16:22:03 +00:00
initTPs({ commit }) {
commit('initTPs')
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
importTPs({ commit }, ao) {
commit('importTPs', ao)
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
clearATIs({ commit }) {
commit('clearATIs')
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
addAT({ commit }, o) {
commit('addAT', o)
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
updateAT({ commit }, o) {
commit('updateAT', o)
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
removeAT({ commit }, n: number) {
commit('removeAT', n)
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
setTD({ commit }, n: number) {
commit('setTD', n)
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
setTS({ commit }, s: string) {
commit('setTS', s)
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
setTV({ commit }, n: number) {
commit('setTV', n)
2021-04-12 18:09:48 +00:00
},
2021-06-18 16:22:03 +00:00
clearIS({ commit }) {
commit('clearIS')
2021-04-12 18:09:48 +00:00
},
2021-06-18 16:22:03 +00:00
setFD({ commit }, n: number) {
commit('setFD', n)
2021-04-01 10:55:35 +00:00
},
2021-06-18 16:22:03 +00:00
setT({ commit }, s: string) {
commit('setT', s)
2021-04-01 10:55:35 +00:00
},
2021-06-18 16:22:03 +00:00
clearF({ commit }) {
commit('clearF')
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
setL({ commit }, s: string) {
commit('setL', s)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
setST({ commit }, s: string) {
commit('setST', s)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
initRs({ commit }) {
commit('initRs')
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
importRsJSON({ commit }, ao) {
commit('importRsJSON', ao)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
importRsDB({ commit }, ao) {
commit('importRsDB', ao)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
addR({ commit }, o) {
commit('addR', o)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
deleteRs({ commit }, a) {
commit('deleteRs', a)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
initLIs({ commit }) {
commit('initLIs')
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
importLIs({ commit }, ao) {
commit('importLIs', ao)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
addLI({ commit }, s: string) {
commit('addLI', s)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
removeLI({ commit }, s: string) {
commit('removeLI', s)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
resetLIs({ commit }, s: string) {
commit('resetLIs', s)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
initMPs({ commit }) {
commit('initMPs')
2021-05-22 08:56:31 +00:00
},
2021-06-18 16:22:03 +00:00
importMPsJSON({ commit }, ao) {
commit('importMPsJSON', ao)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
importMPsDB({ commit }, ao) {
commit('importMPsDB', ao)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
addMP({ commit }, o) {
commit('addMP', o)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
deleteMP({ commit }, o) {
commit('deleteMP', o)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
toggleState({ commit }, o) {
commit('toggleState', o)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
unLinkCs({ commit }, a) {
commit('unLinkCs', a)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
setS({ commit }, n: number) {
commit('setS', n)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
setR({ commit }, n: number) {
commit('setR', n)
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
unLinkBIs({ commit }) {
commit('unLinkBIs')
2021-03-21 17:02:04 +00:00
},
2021-06-18 16:22:03 +00:00
setCuisine({ commit }, s: string) {
commit('setCuisine', s)
2021-04-01 10:55:35 +00:00
},
2021-06-18 16:22:03 +00:00
setCategory({ commit }, s: string) {
commit('setCategory', s)
2021-04-01 10:55:35 +00:00
},
2021-06-18 16:22:03 +00:00
setTag({ commit }, s: string) {
commit('setTag', s)
2021-04-01 10:55:35 +00:00
},
2021-03-21 17:02:04 +00:00
},
})