cleaned code

This commit is contained in:
vishnuraghavb 2021-06-19 00:07:01 +05:30
parent dfbacb66a6
commit 58be4cec5c
22 changed files with 264 additions and 369 deletions

View file

@ -12,7 +12,7 @@
<Button col="1" class="ico" :text="icon.cog" @tap="navigateTo" />
</RGridLayout>
<Timer
v-for="timer in activeTimers"
v-for="timer in activeTs"
:key="timer.id + key"
:timer="timer"
:formattedTime="formattedTime"
@ -21,10 +21,10 @@
:timerAlert="timerAlert"
:showToast="showToast"
/>
<StackLayout class="listSpace"> </StackLayout>
<StackLayout class="ls"> </StackLayout>
</StackLayout>
</ScrollView>
<GridLayout v-if="!activeTimers.length" rows="*, auto">
<GridLayout v-if="!activeTs.length" rows="*, auto">
<StackLayout row="1" class="empty">
<RLabel class="tb t3 tw" :text="'ccwt' | L" />
<RLabel class="tw" :text="'plsAdd' | L" />
@ -115,11 +115,11 @@ export default {
...mapState([
"icon",
"recipes",
"timerSound",
"timerVibrate",
"timerPresets",
"activeTimers",
"FGService",
"timerS",
"timerV",
"timerPs",
"activeTs",
"FGS",
"RTL",
]),
hasBackStack() {
@ -127,18 +127,10 @@ export default {
},
},
methods: {
...mapActions([
"addActiveTimer",
"removeActiveTimer",
"clearTimerInterval",
"addTimerPreset",
"updateActiveTimer",
"setFGService",
]),
...mapActions(["addAT", "removeAT", "clearATIs", "updateAT", "setFgS"]),
pgLoad({ object }) {
object.bindingContext = new Observable();
if (this.activeTimers.filter((e: any) => e.done).length)
this.openReminder();
if (this.activeTs.filter((e: any) => e.done).length) this.openReminder();
setNumber("isTimer", 1);
},
abLoad({ object }) {
@ -188,8 +180,8 @@ export default {
// NOTIFICATION HANDLERS
timerInfo() {
let activeCount = this.activeTimers.length;
let pausedCount = this.activeTimers.filter((e) => e.isPaused).length;
let activeCount = this.activeTs.length;
let pausedCount = this.activeTs.filter((e) => e.isPaused).length;
let ongoingCount = activeCount - pausedCount;
this.foregroundService(activeCount);
function show() {
@ -204,13 +196,12 @@ export default {
title: localize("timer"),
});
}
if (this.FGService)
setTimeout(() => this.activeTimers.length && show(), 250);
if (this.FGS) setTimeout(() => this.activeTs.length && show(), 250);
utils.wakeLock(ongoingCount);
},
timerAlert() {
let title, description, bID;
let firedTimers = this.activeTimers.filter((e) => e.done);
let firedTimers = this.activeTs.filter((e) => e.done);
let timer = firedTimers[0];
if (firedTimers.length > 1) {
title = localize("texp", firedTimers.length);
@ -235,9 +226,9 @@ export default {
multi: firedTimers.length > 1,
nID: 7,
priority: 1,
sound: this.timerSound.uri,
sound: this.timerS.uri,
title,
vibrate: this.timerVibrate,
vibrate: this.timerV,
});
if (firedTimers.length == 1) {
Application.android.registerBroadcastReceiver(bID, (ctx, intent) => {
@ -255,7 +246,7 @@ export default {
}
},
openReminder() {
this.clearTimerInterval();
this.clearATIs();
this.$showModal(TimerReminder, {
fullscreen: true,
props: {
@ -266,7 +257,7 @@ export default {
showToast: this.showToast,
},
}).then(() => {
this.clearTimerInterval();
this.clearATIs();
this.key = Math.floor(Math.random() * 900) + 100;
});
},
@ -276,16 +267,16 @@ export default {
ctx,
com.tns.ForegroundService.class
);
if (n && !this.FGService) {
if (n && !this.FGS) {
parseInt(Device.sdkVersion) < 26
? ctx.startService(intent)
: ctx.startForegroundService(intent);
this.setFGService(1);
setNumber("FGService", 1);
} else if (!this.activeTimers.length) {
this.setFgS(1);
setNumber("FGS", 1);
} else if (!this.activeTs.length) {
ctx.stopService(intent);
this.setFGService(0);
setNumber("FGService", 0);
this.setFgS(0);
setNumber("FGS", 0);
}
},
@ -294,14 +285,14 @@ export default {
this.$showModal(TimePickerHMS, {
props: {
title: "ntmr",
label: `${localize("tmr", this.activeTimers.length + 1)}`,
label: `${localize("tmr", this.activeTs.length + 1)}`,
action: "strtBtn",
showPreset: this.timerPresets.length,
showPreset: this.timerPs.length,
},
}).then((res) => {
if (res) {
if (res == "presets") {
let list = this.timerPresets.map(
let list = this.timerPs.map(
(e) => `${e.label} - ${this.formattedTime(e.time)}`
);
this.$showModal(Action, {
@ -312,22 +303,22 @@ export default {
}).then((preset) => {
if (preset) {
let timer = JSON.parse(
JSON.stringify(this.timerPresets[list.indexOf(preset)])
JSON.stringify(this.timerPs[list.indexOf(preset)])
);
timer.id = utils.getRandomID(1);
timer.recipeID = this.recipeID;
timer.timerInt = timer.isPaused = 0;
timer.preset = timer.mode = 1;
this.addActiveTimer({
this.addAT({
timer,
i: this.activeTimers.length,
i: this.activeTs.length,
});
this.timerInfo();
}
});
} else {
let mode = res.time != "00:00:00" ? 1 : 0;
this.addActiveTimer({
this.addAT({
timer: {
id: utils.getRandomID(1),
label: res.label,
@ -339,7 +330,7 @@ export default {
done: 0,
mode,
},
i: this.activeTimers.length,
i: this.activeTs.length,
});
this.timerInfo();
}
@ -347,11 +338,11 @@ export default {
});
},
removeTimer(id, noUndo) {
let i = this.activeTimers.findIndex((e) => e.id == id);
let temp = this.activeTimers[i];
let i = this.activeTs.findIndex((e) => e.id == id);
let temp = this.activeTs[i];
clearInterval(temp.timerInt);
temp.timerInt = 0;
this.removeActiveTimer(i);
this.removeAT(i);
let secs = [getNumber(`${temp.id}c`, 0), getNumber(`${temp.id}d`, 0)];
function removeSettings() {
remove(`${temp.id}c`);
@ -363,7 +354,7 @@ export default {
.then(() => {
setNumber(`${temp.id}c`, secs[0]),
setNumber(`${temp.id}d`, secs[1]),
this.addActiveTimer({
this.addAT({
timer: temp,
i,
});
@ -377,7 +368,7 @@ export default {
togglePause(timer, n) {
timer.isPaused =
typeof n === "number" ? n : (!timer.isPaused as boolean | 0);
this.updateActiveTimer(timer);
this.updateAT(timer);
n ? 0 : this.timerInfo();
},
showToast(data) {
@ -453,7 +444,7 @@ export default {
// HELPERS
},
created() {
this.clearTimerInterval();
this.clearATIs();
this.recipeID && this.addTimer();
},
destroyed() {

View file

@ -391,7 +391,7 @@ export default {
modalOpen: 0,
saving: 0,
cacheImagePath: null,
unSyncCombinations: [],
unLinkCombs: [],
difficultyLevels: ["Easy", "Moderate", "Challenging"],
appbar: null,
snackbar: null,
@ -427,11 +427,7 @@ export default {
},
},
methods: {
...mapActions([
"addRecipeAction",
"addListItemAction",
"unSyncCombinationsAction",
]),
...mapActions(["addR", "addLI", "unLinkCs"]),
pgLoad({ object }) {
object.bindingContext = new Observable();
this.hijackBackEvent();
@ -491,37 +487,39 @@ export default {
knownFolders.temp().path,
`${utils.getRandomID(0)}.jpg`
);
utils.copyPhotoToCache(uri, this.cacheImagePath).then((imgPath) => {
if (imgPath) {
ImageSource.fromFile(imgPath).then((image) => {
ImageCropper.prototype
.show(
image,
{
width: 1080,
height: 1080,
},
{
hideBottomControls: true,
toolbarTitle: localize("cPic"),
statusBarColor: "#ff5200",
toolbarTextColor: aT == "Light" ? "#212529" : "#f1f3f5",
toolbarColor:
aT == "Light"
? "#f1f3f5"
: aT == "Dark"
? "#212529"
: "#000000",
cropFrameColor: "#ff5200",
}
)
.then((cropped) => {
cropped.image.saveToFile(this.cacheImagePath, "jpg", 75);
this.recipe.image = this.cacheImagePath;
});
});
}
});
utils
.copyPhotoToCache(uri.toString(), this.cacheImagePath)
.then((imgPath) => {
if (imgPath) {
ImageSource.fromFile(imgPath).then((image) => {
ImageCropper.prototype
.show(
image,
{
width: 1080,
height: 1080,
},
{
hideBottomControls: true,
toolbarTitle: localize("cPic"),
statusBarColor: "#ff5200",
toolbarTextColor: aT == "Light" ? "#212529" : "#f1f3f5",
toolbarColor:
aT == "Light"
? "#f1f3f5"
: aT == "Dark"
? "#212529"
: "#000000",
cropFrameColor: "#ff5200",
}
)
.then((cropped) => {
cropped.image.saveToFile(this.cacheImagePath, "jpg", 75);
this.recipe.image = this.cacheImagePath;
});
});
}
});
}
});
},
@ -558,7 +556,7 @@ export default {
this.modalOpen = 0;
if (item.length) {
this.recipe.cuisine = item;
this.addListItemAction({
this.addLI({
item,
listName: "cuisines",
});
@ -572,7 +570,7 @@ export default {
if (focus) this.autoFocusField("category", 0);
} else
this.cuisines.includes(this.recipe.cuisine)
? mull
? null
: (this.recipe.cuisine = "Undefined");
}
});
@ -597,7 +595,7 @@ export default {
this.modalOpen = 0;
if (item.length) {
this.recipe.category = item;
this.addListItemAction({
this.addLI({
item,
listName: "categories",
});
@ -611,7 +609,7 @@ export default {
if (focus) this.autoFocusField("tags", 1);
} else
this.categories.includes(this.recipe.category)
? mull
? null
: (this.recipe.category = "Undefined");
}
});
@ -636,7 +634,7 @@ export default {
this.modalOpen = 0;
if (item.length) {
this.recipe.yieldUnit = item;
this.addListItemAction({
this.addLI({
item,
listName: "yieldUnits",
});
@ -650,7 +648,7 @@ export default {
if (focus) this.autoFocusField("difficultyLevel", 0);
} else
this.yieldUnits.includes(this.recipe.yieldUnit)
? mull
? null
: (this.recipe.yieldUnit = "Serving");
}
});
@ -670,7 +668,7 @@ export default {
if (focus) this.addIngredient();
} else
this.difficultyLevels.includes(this.recipe.difficulty)
? mull
? null
: (this.recipe.difficulty = "Easy");
});
},
@ -694,7 +692,7 @@ export default {
this.modalOpen = 0;
if (item.length) {
this.recipe.ingredients[index].unit = item;
this.addListItemAction({
this.addLI({
item,
listName: "units",
});
@ -785,7 +783,7 @@ export default {
removeCombination(id) {
let index = this.recipe.combinations.indexOf(id);
this.recipe.combinations.splice(index, 1);
this.unSyncCombinations.push(id);
this.unLinkCombs.push(id);
this.showUndoBar("rmCmb").then((res) =>
this.recipe.combinations.splice(index, 0, id)
);
@ -832,14 +830,14 @@ export default {
} else if (this.tempRecipe.image) {
getFileAccess().deleteFile(this.tempRecipe.image);
}
this.unSyncCombinationsAction({
this.unLinkCs({
id: this.recipeID,
combinations: this.unSyncCombinations,
combs: this.unLinkCombs,
});
this.saveRecipe();
},
saveRecipe() {
this.addRecipeAction(this.recipe);
this.addR(this.recipe);
this.saving = 0;
this.dupRecipe
? this.$navigateTo(EnRecipes, {

View file

@ -111,7 +111,7 @@
</RStackLayout>
<RStackLayout :rtl="RTL" class="oh">
<Label class="ico s vc" :text="icon.star" />
<Label class="attr" :text="getLocaleN(recipe.rating)" />
<Label class="attr" :text="localeN(recipe.rating)" />
<Label class="ico s vc" :text="icon.time" />
<Label
class="attr"
@ -383,7 +383,7 @@
class="ico fab"
:text="icon.plus"
col="5"
@tap="addRecipe"
@tap="addR"
/>
<Button
:hidden="!selectMode"
@ -468,7 +468,7 @@ export default {
computed: {
...mapState([
"icon",
"sortType",
"sortT",
"recipes",
"cuisines",
"categories",
@ -479,7 +479,7 @@ export default {
"selCuisine",
"selCategory",
"selTag",
"timerSound",
"timerS",
"RTL",
]),
filteredRecipes() {
@ -586,20 +586,7 @@ export default {
},
},
methods: {
...mapActions([
"initListItems",
"initRecipes",
"initMealPlans",
"initTimerPresets",
"setShake",
"setFirstDay",
"setLayout",
"setSortType",
"deleteRecipes",
"clearFilter",
"setTheme",
"setTimerSound",
]),
...mapActions(["setS", "setST", "deleteRs", "clearF"]),
setComp(comp) {
this.currentComp = comp;
},
@ -615,7 +602,7 @@ export default {
if (this.shake) {
if (utils.hasAccelerometer())
startAccelerometerUpdates((data) => this.onSensorData(data));
else this.setShake(0);
else this.setS(0);
}
this.hijackBackEvent();
setTimeout(() => {
@ -695,12 +682,12 @@ export default {
"Newest first",
"Oldest first",
],
selected: this.sortType,
selected: this.sortT,
},
}).then((action) => {
if (action && this.sortType !== action) {
this.setSortType(action);
ApplicationSettings.setString("sortType", action);
if (action && this.sortT !== action) {
this.setST(action);
ApplicationSettings.setString("sortT", action);
this.updateSort();
}
this.hijackBackEvent();
@ -782,7 +769,7 @@ export default {
},
}).then((action) => {
if (action) {
this.deleteRecipes(this.selection);
this.deleteRs(this.selection);
if (!this.filteredRecipes.length) this.goToHome();
this.clearSelection();
}
@ -883,7 +870,7 @@ export default {
}).length;
break;
}
return count && this.getLocaleN(count);
return count && this.localeN(count);
},
centerLabel({ object }) {
object.android.setGravity(17);
@ -904,7 +891,6 @@ export default {
},
randomRecipeID() {
// TODO: show only from selected filter
let min = 0;
let max = this.filteredRecipes.length - 1;
let randomIndex = Math.round(Math.random() * (max - min));
@ -952,7 +938,7 @@ export default {
}
let dl1 = difficultyLevel(a.difficulty);
let dl2 = difficultyLevel(b.difficulty);
switch (this.sortType) {
switch (this.sortT) {
case "random":
return 0.5 - Math.random();
case "title":
@ -989,7 +975,7 @@ export default {
id == this.filteredRecipes[length - 2].id)
? "lastItem"
: "";
let selection = this.selection.includes(id) ? "selected" : "unselected";
let selection = this.selection.includes(id) ? "select" : "deselect";
let classes = itemPos + " " + selection;
return l2 ? classes + oddOrEven : classes;
},
@ -1034,7 +1020,7 @@ export default {
goToHome() {
this.setComp("EnRecipes");
this.filterFavourites = this.filterTrylater = null;
this.clearFilter();
this.clearF();
},
navigateTo(to, title, page) {
this.showTools && this.toggleTools();
@ -1056,7 +1042,7 @@ export default {
this.setComp(title);
this.filterFavourites = to == "favourites";
this.filterTrylater = to == "trylater";
this.clearFilter();
this.clearF();
}
},
stSwipe({ direction }) {
@ -1070,7 +1056,7 @@ export default {
this.setComp(comps[index - 1]);
this.filterFavourites = comps[index - 1] == "favourites";
this.filterTrylater = comps[index - 1] == "trylater";
this.clearFilter();
this.clearF();
}
break;
case 2:
@ -1084,7 +1070,7 @@ export default {
break;
}
},
addRecipe() {
addR() {
this.showTools && this.toggleTools();
this.$navigateTo(EditRecipe, {
props: {

View file

@ -63,7 +63,7 @@
<v-template if="item.type == 1">
<Label
class="type t3"
:class="{ tb: plannerView == 'd' }"
:class="{ tb: plannerV == 'd' }"
:text="item.mealType | L"
/>
</v-template>
@ -132,7 +132,7 @@
</RGridLayout>
</v-template>
<v-template>
<StackLayout class="listSpace"> </StackLayout>
<StackLayout class="ls"> </StackLayout>
</v-template>
</CollectionView>
</StackLayout>
@ -246,9 +246,9 @@ export default {
"recipes",
"layout",
"mealPlans",
"mondayFirst",
"startMon",
"RTL",
"plannerView",
"plannerV",
]),
todaysTime() {
return new Date(this.year, this.month, this.date, 0).getTime();
@ -269,12 +269,12 @@ export default {
calRows() {
let h = (Screen.mainScreen.widthDIPs - 32) / 8;
if (h < 48) h = 48;
let pv = this.plannerView;
let pv = this.plannerV;
return pv != "d" ? `${h}, `.repeat(pv == "wk" ? 1 : 6) + h : 0;
},
getDayNames() {
let dNames =
this.plannerView != "d" &&
this.plannerV != "d" &&
this.getCal.slice(0, 7).map((d) => {
let date = new Date(d.y, d.m, d.d);
return new Intl.DateTimeFormat(null, {
@ -293,7 +293,7 @@ export default {
) {
a.push({
d: d.getDate(),
ld: this.getLocaleN(d.getDate()),
ld: this.localeN(d.getDate()),
m: d.getMonth(),
y: d.getFullYear(),
});
@ -301,15 +301,15 @@ export default {
return a;
};
let pv = this.plannerView;
let pv = this.plannerV;
let date = new Date(
this.year,
this.month,
pv == "mnth" ? 1 : this.date - this.mondayFirst
pv == "mnth" ? 1 : this.date - this.startMon
);
return pv != "d"
? getDays(
date.setDate(date.getDate() - date.getDay() + this.mondayFirst),
date.setDate(date.getDate() - date.getDay() + this.startMon),
date.setDate(date.getDate() + (pv == "mnth" ? 41 : 6))
)
: [];
@ -332,7 +332,7 @@ export default {
return /minimal/.test(this.layout);
},
mpItems() {
let pv = this.plannerView;
let pv = this.plannerV;
let days =
pv == "wk"
? this.getCal.slice(0, 7)
@ -387,7 +387,7 @@ export default {
},
},
methods: {
...mapActions(["addMealPlanAction", "deleteMealPlanAction"]),
...mapActions(["addMP", "deleteMP"]),
pgLoad({ object }) {
object.bindingContext = new Observable();
this.showBar();
@ -439,7 +439,7 @@ export default {
getYield(id) {
let mp = this.mealPlans.filter((e) => e.id == id)[0];
let r = this.recipes.filter((e) => e.id === mp.recipeID)[0];
return r ? `${this.getLocaleN(mp.quantity)} ${localize(r.yieldUnit)}` : 0;
return r ? `${this.localeN(mp.quantity)} ${localize(r.yieldUnit)}` : 0;
},
// NavigationHandlers
@ -476,7 +476,7 @@ export default {
// Calendar
navigate(dir) {
if (this.RTL) dir = !dir;
let pv = this.plannerView;
let pv = this.plannerV;
let date = new Date(this.year, this.month, this.date);
let sd =
pv == "mnth"
@ -557,7 +557,7 @@ export default {
// DataHandlers
newMealPlan({ plan, index, inDB }) {
this.addMealPlanAction({
this.addMP({
plan,
index,
inDB,
@ -655,7 +655,7 @@ export default {
deleteTempFromDB() {
if (this.temp) {
let { plan, index } = this.temp;
this.deleteMealPlanAction({ id: plan.id, index, inDB: 1 });
this.deleteMP({ id: plan.id, index, inDB: 1 });
this.temp = 0;
}
},
@ -664,11 +664,11 @@ export default {
let index = this.mealPlans.findIndex((e) => e.id == id);
let plan = this.mealPlans.filter((e) => e.id == id)[0];
this.temp = { plan, index };
this.deleteMealPlanAction({ id, index });
this.deleteMP({ id, index });
this.showUndoBar(plan.note ? "rmN" : "recRm")
.then(() => this.newMealPlan({ plan, index }))
.catch(() => {
this.deleteMealPlanAction({ id, index, inDB: 1 });
this.deleteMP({ id, index, inDB: 1 });
});
},
showUndoBar(message) {
@ -750,7 +750,7 @@ export default {
options.year = "numeric";
options.month = "long";
}
if (this.plannerView == "d") {
if (this.plannerV == "d") {
options.weekday = "long";
options.day = "numeric";
options.month = "short";

View file

@ -51,60 +51,57 @@
>
<StackLayout>
<RGridLayout :rtl="RTL" rows="auto" columns="*, *">
<StackLayout class="attribute">
<StackLayout class="attrT">
<RLabel class="sub" :text="'cui' | L" />
<RLabel class="value" :text="recipe.cuisine | L" />
<RLabel class="v" :text="recipe.cuisine | L" />
</StackLayout>
<StackLayout class="attribute" col="1">
<StackLayout class="attrT" col="1">
<RLabel class="sub" :text="'cat' | L" />
<RLabel class="value" :text="recipe.category | L" />
<RLabel class="v" :text="recipe.category | L" />
</StackLayout>
</RGridLayout>
<StackLayout
:hidden="!recipe.tags.length"
class="attribute hal"
class="attrT hal"
:class="{ r: RTL }"
>
<RLabel class="sub" :text="'ts' | L" />
<RLabel class="value" :text="getTags(recipe.tags)" />
<RLabel class="v" :text="getTags(recipe.tags)" />
</StackLayout>
<RGridLayout :rtl="RTL" rows="auto" columns="*, *">
<StackLayout
class="attribute"
:hidden="!hasTime(recipe.prepTime)"
>
<StackLayout class="attrT" :hidden="!hasTime(recipe.prepTime)">
<RLabel class="sub" :text="'prepT' | L" />
<RLabel
class="value"
class="v"
:text="formattedTime(recipe.prepTime)"
/>
</StackLayout>
<StackLayout
:col="hasTime(recipe.prepTime) ? 1 : 0"
class="attribute"
class="attrT"
:hidden="!hasTime(recipe.cookTime)"
>
<RLabel class="title sub" :text="'cookT' | L" />
<RLabel
class="value"
class="v"
:text="formattedTime(recipe.cookTime)"
/>
</StackLayout>
</RGridLayout>
<RGridLayout :rtl="RTL" rows="auto" columns="*, *">
<StackLayout class="attribute">
<StackLayout class="attrT">
<RLabel class="title sub" :text="'yld' | L" />
<RLabel
@touch="touchYield"
class="value accent"
class="v accent"
:text="`${tempYieldQuantity} ${$options.filters.L(
recipe.yieldUnit
)}`"
/>
</StackLayout>
<StackLayout class="attribute" col="1">
<StackLayout class="attrT" col="1">
<RLabel class="title sub" :text="'Difficulty level' | L" />
<RLabel class="value" :text="recipe.difficulty | L" />
<RLabel class="v" :text="recipe.difficulty | L" />
</StackLayout>
</RGridLayout>
<StackLayout @loaded="onIngsLoad">
@ -139,7 +136,7 @@
:key="index + 'ins'"
class="check"
>
<Button class="tb t3 ico si" :text="getLocaleN(index + 1)" />
<Button class="tb t3 ico si" :text="localeN(index + 1)" />
<RLabel class="v tw" :text="instruction" />
</RStackLayout>
</StackLayout>
@ -152,7 +149,7 @@
<Button
v-for="(combination, index) in recipe.combinations"
:key="index + 'comb'"
class="comb tw hal lh4 fb"
class="note tw hal lh4 fb"
:class="{ r: RTL }"
:text="getCombinationTitle(combination)"
@tap="viewCombination(combination)"
@ -264,7 +261,7 @@
stretch="aspectFit"
@loaded="onImgViewLoad"
:src="recipe.image"
class="imgViewer"
class="imgV"
/>
</AbsoluteLayout>
<WebView @loaded="wvLoad" hidden />
@ -343,7 +340,7 @@ export default {
};
},
computed: {
...mapState(["icon", "recipes", "RTL", "awakeViewer"]),
...mapState(["icon", "recipes", "RTL", "awakeV"]),
tempYieldQuantity() {
return Math.abs(this.yieldMultiplier) > 0
? Math.abs(parseFloat(this.yieldMultiplier))
@ -372,13 +369,13 @@ export default {
},
},
methods: {
...mapActions(["toggleStateAction", "setRatingAction", "toggleCartAction"]),
...mapActions(["toggleState", "setR"]),
pgLoad({ object }) {
this.busyDup = this.busyEdit = this.photoOpen = 0;
object.bindingContext = new Observable();
if (this.yieldMultiplier == this.recipe.yieldQuantity)
this.yieldMultiplier = this.recipe.yieldQuantity;
if (this.awakeViewer) utils.keepScreenOn(1);
if (this.awakeV) utils.keepScreenOn(1);
this.syncCombinations();
this.view = object.page.getViewById("printview");
},
@ -504,8 +501,8 @@ export default {
s = this.stepsDid;
break;
}
c = this.getLocaleN(c);
s = s && this.getLocaleN(s);
c = this.localeN(c);
s = s && this.localeN(s);
let text = s ? ` (${s}/${c})` : ` (${c})`;
return localize(title) + text;
},
@ -572,48 +569,6 @@ export default {
: this.animateBar(this.appbar, 1);
});
},
// getMeasure(value: number, unit: string) {
// let vm = this;
// function roundedQ(val: number) {
// return Math.abs(
// Math.round(
// (val / vm.recipe.yieldQuantity) * vm.tempYieldQuantity * 100
// ) / 100
// );
// }
// if (value) {
// let rounded = Math.abs(
// Math.round(
// (value / this.recipe.yieldQuantity) * this.tempYieldQuantity * 100
// ) / 100
// );
// let lUnit = localize(unit);
// switch (unit) {
// //IMPERIAL
// case "g":
// return rounded < 1000
// ? `${rounded} ${lUnit} `
// : `${roundedQ(rounded / 1000)} ${localize("kg")} `;
// case "ml":
// return rounded < 1000
// ? `${rounded} ${lUnit} `
// : `${roundedQ(rounded / 1000)} ${localize("l")} `;
// //METRIC
// case "tsp":
// return rounded < 3
// ? `${rounded} ${lUnit} `
// : `${roundedQ(rounded / 3)} ${localize("tbsp")} `;
// case "in":
// return rounded < 12
// ? `${rounded} ${lUnit} `
// : `${roundedQ(rounded / 12)} ${localize("ft")} `;
// default:
// return `${rounded} ${lUnit} `;
// }
// } else return "";
// },
roundedQuantity(quantity: number) {
return Math.abs(
Math.round(
@ -830,7 +785,7 @@ export default {
// DataHandlers
toggle(key: string, setDate: boolean) {
this.toggleStateAction({
this.toggleState({
id: this.currentRecipeID,
key,
setDate,
@ -844,22 +799,14 @@ export default {
setRating(r) {
if (r !== this.recipe.rating || r === 1) {
if (this.recipe.rating == 1 && r == 1) r = 0;
this.setRatingAction({
this.setR({
id: this.currentRecipeID,
rating: r,
r,
});
}
},
// ShoppingList
toggleCart() {
if (!this.recipe.inBag) {
} else {
}
this.toggleCartAction({
id: this.currentRecipeID,
});
},
// Notes
createNote(note) {

View file

@ -80,10 +80,10 @@ export default {
};
},
computed: {
...mapState(["sortType", "icon", "theme", "RTL"]),
...mapState(["icon", "theme", "RTL"]),
},
methods: {
...mapActions(["removeListItemAction", "deleteTimerPreset"]),
...mapActions(["removeLI", "deleteTP"]),
localized(item: string): string {
return this.title !== "lang" ? localize(item) : item;
},
@ -114,22 +114,22 @@ export default {
let vm = this;
let index = this.newList.findIndex((e) => e === item);
let localizedItem = `"${localize(item)}"`;
function removeListItem(listName: string, desc: string): void {
function removeLI(listName: string, desc: string): void {
vm.removeConfirmation(`${localize(desc, localizedItem)}`).then(
(action: boolean) => {
if (action)
vm.removeListItemAction({
vm.removeLI({
item,
listName,
});
}
);
}
function deleteTimerPreset(): void {
function deleteTP(): void {
vm.deletionConfirmation(`${localize("delPrst", `"${item}"`)}`).then(
(action: boolean) => {
if (action) {
vm.deleteTimerPreset(index);
vm.deleteTP(index);
vm.newList.splice(index, 1);
}
}
@ -137,19 +137,19 @@ export default {
}
switch (this.title) {
case "cui":
removeListItem("cuisines", "rmCuiInfo");
removeLI("cuisines", "rmCuiInfo");
break;
case "cat":
removeListItem("categories", "rmCatInfo");
removeLI("categories", "rmCatInfo");
break;
case "yieldU":
removeListItem("yieldUnits", "rmYUInfo");
removeLI("yieldUnits", "rmYUInfo");
break;
case "Unit":
removeListItem("units", "rmUInfo");
removeLI("units", "rmUInfo");
break;
case "prsts":
deleteTimerPreset();
deleteTP();
break;
}
},

View file

@ -1,15 +1,11 @@
<template>
<Page
@loaded="mLoad"
backgroundColor="transparent"
:class="theme"
>
<Page @loaded="mLoad" backgroundColor="transparent" :class="theme">
<GridLayout rows="auto, auto, auto" class="modal">
<RLabel class="title" :text="title | L" />
<Label
row="1"
v-if="description"
class="description tw"
class="desc input tw lh4"
:text="description"
/>
<RGridLayout :rtl="RTL" row="2" columns="*, auto, auto" class="actions">

View file

@ -173,7 +173,7 @@ export default {
},
},
methods: {
...mapActions(["setCuisine", "setCategory", "setTag", "clearFilter"]),
...mapActions(["setCuisine", "setCategory", "setTag"]),
pgLoad(args) {
this.mLoad(args);
this.localCuisine = this.selCuisine;

View file

@ -57,7 +57,7 @@
col="3"
class="text tb st fb"
:text="action | L"
@tap="sendRespose"
@tap="respond"
/>
</RGridLayout>
</GridLayout>
@ -122,7 +122,7 @@ export default {
object.focus();
setTimeout(() => Utils.ad.showSoftInput(object.android), 100);
},
sendRespose() {
respond() {
this.$modal.close({
label: this.setLabel ? this.setLabel : this.label,
time: this.selectedTime,

View file

@ -21,7 +21,7 @@
:timerAlert="timerAlert"
:showToast="showToast"
/>
<StackLayout class="listSpace"> </StackLayout>
<StackLayout class="ls"> </StackLayout>
</StackLayout>
</ScrollView>
<GridLayout col="1" row="1" class="appbar">
@ -42,10 +42,9 @@
import { Application, Screen, Device, Color, Utils } from "@nativescript/core";
import Timer from "../sub/Timer.vue";
import * as utils from "~/shared/utils";
import { mapState, mapActions } from "vuex";
import { mapState } from "vuex";
const windowMgr = android.view.WindowManager;
const View = android.view.View as any;
const ViewGroup = android.view.ViewGroup;
export default {
components: { Timer },
props: [
@ -56,12 +55,12 @@ export default {
"showToast",
],
computed: {
...mapState(["icon", "theme", "activeTimers"]),
...mapState(["icon", "theme", "activeTs"]),
screenWidth() {
return Screen.mainScreen.widthDIPs;
},
timers() {
let timers = this.activeTimers.filter((e) => e.done);
let timers = this.activeTs.filter((e) => e.done);
if (!timers.length) {
this.$modal.close(1);
this.isScreenLocked && this.turnOffScreen();
@ -81,7 +80,6 @@ export default {
},
},
methods: {
...mapActions(["clearTimerInterval"]),
pgLoad({ object }) {
let dialog = object._dialogFragment.getDialog();
let dialogWindow = dialog.getWindow();

View file

@ -6,16 +6,16 @@
<Label class="pTitle tw tb" :text="'About' | L" />
</v-template>
<v-template if="$index == 1">
<StackLayout class="app-info">
<Image class="icon" src="res://logo" stretch="none" />
<StackLayout class="appInfo">
<Image class="logo" src="res://logo" stretch="none" />
<Label class="name tb tc" :text="'EnRecipes' | L" />
<Label :text="getVersion" class="version tb tc" />
<Label :text="getVersion" class="tb tc" />
<Label class="info tc tw" :text="'appInfo' | L" />
<Label class="info tc tw lh4" :text="'appInfo' | L" />
</StackLayout>
</v-template>
<v-template if="$index == 8">
<StackLayout class="listSpace"> </StackLayout>
<StackLayout class="ls"> </StackLayout>
</v-template>
<v-template>
<RGridLayout
@ -105,13 +105,9 @@ export default {
pgLoad({ object }) {
object.bindingContext = new Observable();
},
// HELPERS
openURL(url) {
Utils.openUrl(url);
},
touch({ object, action }, url) {
this.touchFade(object, action);
if (action == "up") this.openURL(url);
if (action == "up") Utils.openUrl(url);
},
},
};

View file

@ -77,7 +77,6 @@ export default {
pgLoad({ object }) {
object.bindingContext = new Observable();
},
// HELPERS
navigateTo(view) {
this.$navigateTo(view, {
animated: false,

View file

@ -33,7 +33,7 @@ import * as utils from "~/shared/utils";
export default {
components: { OptionsList },
computed: {
...mapState(["icon", "timerDelay", "timerSound", "timerVibrate", "RTL"]),
...mapState(["icon", "timerD", "timerS", "timerV", "RTL"]),
items() {
let options = [
{
@ -41,7 +41,7 @@ export default {
icon: "sound",
rtl: 0,
title: "tmrSnd",
subTitle: this.timerSound.title,
subTitle: this.timerS.title,
action: this.showSoundsList,
},
{
@ -49,7 +49,7 @@ export default {
icon: "vibrate",
rtl: 0,
title: "tmrvbrt",
checked: !!this.timerVibrate,
checked: !!this.timerV,
action: this.toggleTimerVibrate,
},
];
@ -72,9 +72,8 @@ export default {
rtl: 0,
title: "dlyDur",
subTitle:
this.delayList[
this.delayList.findIndex((e) => e.n == this.timerDelay)
].l,
this.delayList[this.delayList.findIndex((e) => e.n == this.timerD)]
.l,
action: this.showDelayList,
},
...list,
@ -87,14 +86,14 @@ export default {
...Array.from(Array(6), (_, x) => (x + 1) * 5),
].map((e) => {
return {
l: `${this.getLocaleN(e)} ${localize(e > 1 ? "minutes" : "minute")}`,
l: `${this.localeN(e)} ${localize(e > 1 ? "minutes" : "minute")}`,
n: e,
};
});
},
},
methods: {
...mapActions(["setTimerDelay", "setTimerSound", "setTimerVibrate"]),
...mapActions(["setTD", "setTS", "setTV"]),
pgLoad({ object }) {
object.bindingContext = new Observable();
ApplicationSettings.setNumber("isTimer", 2);
@ -104,12 +103,12 @@ export default {
props: {
title: "dlyDur",
list: this.delayList.map((e) => e.l),
selected: this.delayList.findIndex((e) => e.n == this.timerDelay),
selected: this.delayList.findIndex((e) => e.n == this.timerD),
},
}).then(
(res) =>
res &&
this.setTimerDelay(
this.setTD(
this.delayList[this.delayList.findIndex((e) => e.l == res)].n
)
);
@ -121,18 +120,18 @@ export default {
title: "tmrSnd",
list: getTones.tones.map((e) => e.title),
selected: getTones.tones.findIndex(
(e) => e.title == this.timerSound.title
(e) => e.title == this.timerS.title
),
},
}).then(
(tone) =>
tone &&
tone !== this.timerSound.title &&
this.setTimerSound(getTones.tones.filter((e) => e.title === tone)[0])
tone !== this.timerS.title &&
this.setTS(getTones.tones.filter((e) => e.title === tone)[0])
);
},
toggleTimerVibrate() {
this.setTimerVibrate(!this.timerVibrate | 0);
this.setTV(!this.timerV | 0);
},
openNotificationChannelSettings() {
const ctx = Application.android.context;
@ -147,8 +146,6 @@ export default {
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(intent);
},
// HELPERS
channelExists() {
if (Device.sdkVersion * 1 >= 26) {
const ctx = Utils.ad.getApplicationContext();

View file

@ -75,7 +75,7 @@ export default {
"yieldUnits",
"units",
"mealPlans",
"importSummary",
"impSum",
"RTL",
]),
items() {
@ -108,14 +108,14 @@ export default {
},
methods: {
...mapActions([
"importListItems",
"importRecipesFromJSON",
"importRecipesFromDB",
"importMealPlansFromJSON",
"importMealPlansFromDB",
"importTimerPresets",
"unlinkBrokenImages",
"clearImportSummary",
"importLIs",
"importRsJSON",
"importRsDB",
"importMPsJSON",
"importMPsDB",
"importTPs",
"unLinkBIs",
"clearIS",
]),
pgLoad({ object }) {
object.bindingContext = new Observable();
@ -144,10 +144,8 @@ export default {
android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION |
android.content.Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
utils.getBackupFolder().then((uri) => {
console.log(uri.toString());
if (uri != null) {
// ReleaseExistingPermissions
if (this.backupFolder && this.backupFolder != uri.toString())
ContentResolver.releasePersistableUriPermission(
new android.net.Uri.parse(this.backupFolder),
@ -256,7 +254,7 @@ export default {
function importImages() {
const timer = setInterval(() => {
if (!vm.progress) clearInterval(timer);
if (vm.progress && vm.importSummary.found) {
if (vm.progress && vm.impSum.found) {
Folder.exists(images)
? vm.importImages(uri)
: vm.showImportSummary();
@ -270,8 +268,6 @@ export default {
importImages();
} else if (File.exists(recipes)) {
// IMPORT FROM JSON FILES
console.log("import from json");
this.isFileDataValid([
{
path: recipes,
@ -309,7 +305,6 @@ export default {
} else this.failedImport(localize("buInc"));
},
isFileDataValid(file) {
console.log("isFileDataValid");
const files = file.filter((e) => File.exists(e.path));
if (files.length) {
let isValid = files.map(() => 0);
@ -362,7 +357,7 @@ export default {
// Import recipes
db.select("SELECT * FROM recipes").then((res) => {
this.importRecipesFromDB(res);
this.importRsDB(res);
});
// Import listitems
@ -370,7 +365,7 @@ export default {
`SELECT cuisines, categories, yieldUnits, units FROM lists`
).then((res) =>
Object.keys(res[0]).forEach((listName) =>
this.importListItems({
this.importLIs({
data: JSON.parse(res[0][listName]),
listName,
})
@ -379,46 +374,45 @@ export default {
// Import mealPlans
db.select(`SELECT * FROM mealPlans`).then((res) =>
this.importMealPlansFromDB(res)
this.importMPsDB(res)
);
// Import timerPresets
// Import timerPs
db.select(`SELECT * FROM timerPresets`).then((res) =>
this.importTimerPresets(res)
this.importTPs(res)
);
},
importData(data, db) {
console.log("importing");
switch (db) {
case "recipes":
this.importRecipesFromJSON(data);
this.importRsJSON(data);
break;
case "userCuisines":
this.importListItems({
this.importLIs({
data,
listName: "cuisines",
});
break;
case "userCategories":
this.importListItems({
this.importLIs({
data,
listName: "categories",
});
break;
case "userYieldUnits":
this.importListItems({
this.importLIs({
data,
listName: "yieldUnits",
});
break;
case "userUnits":
this.importListItems({
this.importLIs({
data,
listName: "units",
});
break;
case "mealPlans":
this.importMealPlansFromJSON(data);
this.importMPsJSON(data);
break;
}
},
@ -437,14 +431,14 @@ export default {
});
});
this.showImportSummary();
this.unlinkBrokenImages();
this.unLinkBIs();
}
});
},
showImportSummary() {
this.progress = null;
this.releaseBackEvent();
let { found, imported, updated } = this.importSummary;
let { found, imported, updated } = this.impSum;
let exists = Math.abs(found - imported - updated) + updated;
let importedNote = `\n${localize("recI")} ${imported}`;
let existsNote = `\n${localize("recE")} ${exists}`;
@ -457,7 +451,7 @@ export default {
)}\n${importedNote}${existsNote}${updatedNote}`,
okButtonText: "OK",
},
}).then(() => this.clearImportSummary());
}).then(() => this.clearIS());
},
// NAVIGATION HANDLERS

View file

@ -32,7 +32,7 @@ export default {
};
},
computed: {
...mapState(["icon", "language", "theme", "layout", "RTL"]),
...mapState(["icon", "langs", "theme", "layout", "RTL"]),
items() {
return [
{},
@ -65,13 +65,13 @@ export default {
},
},
methods: {
...mapActions(["setTheme", "setLayout", "setRTL"]),
...mapActions(["setT", "setL", "setRTL"]),
pgLoad({ object }) {
object.bindingContext = new Observable();
},
// LANGUAGE SELECTION
// LanguageSelection
setAppLang() {
let languages = this.language.map((e) => e.title);
let languages = this.langs.map((e) => e.title);
this.$showModal(Action, {
props: {
title: "lang",
@ -84,8 +84,7 @@ export default {
"appLocale",
"none"
).split("-");
let locale = this.language.filter((e) => e.title === action)[0]
.locale;
let locale = this.langs.filter((e) => e.title === action)[0].locale;
if (currentLocale !== locale) {
this.applang = action;
ApplicationSettings.setString("applang", action);
@ -97,7 +96,7 @@ export default {
}
});
},
// THEME SELECTION
// ThemeSelection
selectThemes() {
this.$showModal(Action, {
props: {
@ -112,12 +111,12 @@ export default {
? 1
: this.theme != action)
) {
this.setTheme(action);
this.setT(action);
Frame.reloadPage();
}
});
},
// LAYOUT MODE
// LayoutMode
setLayoutMode() {
this.$showModal(Action, {
props: {
@ -126,7 +125,7 @@ export default {
selected: this.layout,
},
}).then((mode) => {
if (mode && this.layout !== mode) this.setLayout(mode.toLowerCase());
if (mode && this.layout !== mode) this.setL(mode.toLowerCase());
});
},
},

View file

@ -26,7 +26,7 @@ import { localize } from "@nativescript/localize";
export default {
components: { OptionsList },
computed: {
...mapState(["icon", "mondayFirst", "RTL", "plannerView", "planDeletion"]),
...mapState(["icon", "startMon", "RTL", "plannerV", "planDel"]),
items() {
return [
{},
@ -34,21 +34,21 @@ export default {
type: "list",
icon: "calv",
title: "calVM",
subTitle: localize(this.plannerView),
subTitle: localize(this.plannerV),
action: this.selectPlannerView,
},
{
type: "switch",
icon: "week",
title: "swm",
checked: !!this.mondayFirst,
checked: !!this.startMon,
action: this.toggleFirstDay,
},
{
type: "list",
icon: "mpd",
title: "admp",
subTitle: localize(this.planDeletion),
subTitle: localize(this.planDel),
action: this.selectDeletionTime,
},
{},
@ -56,22 +56,22 @@ export default {
},
},
methods: {
...mapActions(["setFirstDay", "setPlannerView", "setPlanDeletion"]),
...mapActions(["setFD", "setPlannerV", "setPlanDel"]),
pgLoad({ object }) {
object.bindingContext = new Observable();
},
toggleFirstDay() {
this.setFirstDay(!this.mondayFirst | 0);
this.setFD(!this.startMon | 0);
},
selectPlannerView() {
this.$showModal(Action, {
props: {
title: "calVM",
list: ["d", "wk", "mnth"],
selected: this.plannerView,
selected: this.plannerV,
},
}).then((res) => {
if (res && this.plannerView != res) this.setPlannerView(res);
if (res && this.plannerV != res) this.setPlannerV(res);
});
},
selectDeletionTime() {
@ -79,10 +79,10 @@ export default {
props: {
title: "admp",
list: ["otaw", "otam", "otay", "nvr"],
selected: this.planDeletion,
selected: this.planDel,
},
}).then((res) => {
if (res && this.planDeletion != res) this.setPlanDeletion(res);
if (res && this.planDel != res) this.setPlanDel(res);
});
},
},

View file

@ -42,7 +42,7 @@ export default {
};
},
computed: {
...mapState(["icon", "shake", "RTL", "edgeSwipe", "awakeViewer"]),
...mapState(["icon", "shake", "RTL", "edgeS", "awakeV"]),
items() {
return [
{},
@ -59,7 +59,7 @@ export default {
icon: "awake",
title: "ksavr",
subTitle: localize("ksavrInfo"),
checked: !!this.awakeViewer,
checked: !!this.awakeV,
action: this.toggleAwake,
},
{
@ -67,7 +67,7 @@ export default {
icon: "edge",
title: "esgb",
subTitle: localize("esgbInfo"),
checked: !!this.edgeSwipe,
checked: !!this.edgeS,
action: this.toggleSwipe,
},
{},
@ -75,7 +75,7 @@ export default {
},
},
methods: {
...mapActions(["setShake", "toggleEdgeSwipe", "toggleAwakeViewer"]),
...mapActions(["setS", "toggleEdgeS", "toggleAwakeV"]),
pgLoad({ object }) {
object.bindingContext = new Observable();
},
@ -90,13 +90,13 @@ export default {
let checked = this.shake;
if (checked && !utils.hasAccelerometer())
this.showToast(localize("noAccSensor"));
else this.setShake(+!checked);
else this.setS(+!checked);
},
toggleSwipe() {
this.toggleEdgeSwipe(+!this.edgeSwipe);
this.toggleEdgeS(+!this.edgeS);
},
toggleAwake() {
this.toggleAwakeViewer(+!this.awakeViewer);
this.toggleAwakeV(+!this.awakeV);
},
showToast(data) {

View file

@ -1,7 +1,7 @@
<template>
<Page @loaded="pgLoad" actionBarHidden="true">
<RGridLayout :rtl="RTL" rows="*, auto" columns="auto, *">
<OptionsList title="rest" :items="items" :action="resetListItems" />
<OptionsList title="rest" :items="items" :action="reset" />
<GridLayout
:hidden="toast"
row="1"
@ -83,7 +83,7 @@ export default {
},
},
methods: {
...mapActions(["resetListItemsAction"]),
...mapActions(["resetLIs"]),
pgLoad({ object }) {
object.bindingContext = new Observable();
},
@ -93,9 +93,8 @@ export default {
tbLoad({ object }) {
this.toastbar = object;
},
// RESET
resetListItems(listName) {
this.resetListItemsAction(listName);
reset(list) {
this.resetLIs(list);
this.showToast();
},
showToast() {

View file

@ -52,13 +52,13 @@
</v-template>
<v-template if="item.type == 'info'">
<Label
class="group-info sub tw"
class="groupInfo sub tw lh4"
:class="{ r: RTL }"
:text="item.title | L"
/>
</v-template>
<v-template>
<StackLayout class="listSpace"> </StackLayout>
<StackLayout class="ls"> </StackLayout>
</v-template>
</ListView>
</template>

View file

@ -82,7 +82,7 @@ export default {
};
},
computed: {
...mapState(["icon", "recipes", "timerDelay", "timerPresets", "RTL"]),
...mapState(["icon", "recipes", "timerD", "timerPs", "RTL"]),
getRecipeTitle() {
let { recipeID } = this.timer;
if (recipeID) {
@ -137,12 +137,7 @@ export default {
},
},
methods: {
...mapActions([
"removeActiveTimer",
"addTimerPreset",
"deleteTimerPreset",
"sortActiveTimers",
]),
...mapActions(["addTP", "sortATs"]),
pLoaded({ object }) {
this.pBar = object.android;
this.pBar.setRotation(
@ -165,7 +160,7 @@ export default {
} else if (res) {
let timer = this.timer;
timer.recipeID = res;
this.sortActiveTimers();
this.sortATs();
}
});
},
@ -211,7 +206,7 @@ export default {
this.timer.isPaused ? this.resetInterval() : this.initTimer();
},
addPreset() {
let exist = this.timerPresets.some((e) => e.id == this.timer.id);
let exist = this.timerPs.some((e) => e.id == this.timer.id);
this.timer.preset = 1;
if (this.countUp) {
this.timer.time = new Date(this.count * 1000)
@ -221,14 +216,14 @@ export default {
let timer = JSON.parse(JSON.stringify(this.timer));
let { recipeID, timerInt, isPaused, preset, done, mode, ...presetTimer } =
timer;
this.addTimerPreset(presetTimer);
this.addTP(presetTimer);
exist ? this.showToast("prstTU") : this.showToast("aTPrst");
},
addDelay() {
this.timer.done = 0;
let td = this.timerDelay;
let td = this.timerD;
let delayDur =
this.getLocaleN(td) + " " + localize(td > 1 ? "minutes" : "minute");
this.localeN(td) + " " + localize(td > 1 ? "minutes" : "minute");
this.showToast(localize("wDBy", this.timer.label, delayDur));
let delay = td * 60;
if (this.done) this.delay = delay;

View file

@ -40,15 +40,15 @@ Vue.filter('L', localize)
const initFrame = () => {
const s = store
// MainInit
s.commit('setTheme', getString('theme', 'sysDef'))
s.commit('initRecipes')
s.commit('initMealPlans')
s.commit('initListItems')
s.commit('initTimerPresets')
if (!Object.keys(s.state.timerSound).length) {
let hasTimerSound = getString('timerSound', null)
s.commit('setT', getString('theme', 'sysDef'))
s.commit('initRs')
s.commit('initMPs')
s.commit('initLIs')
s.commit('initTPs')
if (!Object.keys(s.state.timerS).length) {
let hasTimerSound = getString('timerS', null)
s.commit(
'setTimerSound',
'setTS',
hasTimerSound ? JSON.parse(hasTimerSound) : utils.getTones().defaultTone
)
}

View file

@ -1051,7 +1051,7 @@ export default new Vuex.Store({
// DeleteMealPlan
deleteMP(
state,
{ id, index, inDB }: { id: string; index: number; inDB: number }
{ id, index, inDB }: { id: string; index: number; inDB?: number }
) {
if (inDB) {
db.execute(`DELETE FROM mealPlans WHERE id = '${id}'`)
@ -1074,9 +1074,9 @@ export default new Vuex.Store({
}
},
// UnLinkCombinations
unLinkCs(state, { id, a }) {
unLinkCs(state, { id, combs }) {
state.recipes.forEach((e, i) => {
if (a.includes(e.id)) {
if (combs.includes(e.id)) {
state.recipes[i].combinations.splice(e.combinations.indexOf(id), 1)
db.execute(
`UPDATE recipes SET combinations = '${JSON.stringify(
@ -1092,10 +1092,10 @@ export default new Vuex.Store({
setNumber('shake', n)
},
// SetRating
setR(state, { id, rating }) {
setR(state, { id, r }) {
let i = state.recipes.findIndex((e) => e.id == id)
state.recipes[i].rating = rating
db.execute(`UPDATE recipes SET rating = ${rating} WHERE id = '${id}'`)
state.recipes[i].rating = r
db.execute(`UPDATE recipes SET rating = ${r} WHERE id = '${id}'`)
},
// UnLinkBrokenImages
unLinkBIs(state) {