mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 00:12:11 +08:00
use for-of statements to replace for and for-in
This commit is contained in:
@@ -168,7 +168,7 @@ describe('getFiscalYearStartUnixTime', () => {
|
||||
const expected = testCase.expected[testFiscalYearStart.id];
|
||||
const unixTimeISO = formatUnixTimeISO(startUnixTime);
|
||||
|
||||
expect({ unixTime: startUnixTime, ISO: unixTimeISO }).toStrictEqual({ unixTime: expected.unixTime, ISO: expected.unixTimeISO });
|
||||
expect({ unixTime: startUnixTime, ISO: unixTimeISO }).toStrictEqual({ unixTime: expected!.unixTime, ISO: expected!.unixTimeISO });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -198,7 +198,7 @@ describe('getFiscalYearEndUnixTime', () => {
|
||||
const expected = testCase.expected[testFiscalYearStart.id];
|
||||
const unixTimeISO = formatUnixTimeISO(endUnixTime);
|
||||
|
||||
expect({ unixTime: endUnixTime, ISO: unixTimeISO }).toStrictEqual({ unixTime: expected.unixTime, ISO: expected.unixTimeISO });
|
||||
expect({ unixTime: endUnixTime, ISO: unixTimeISO }).toStrictEqual({ unixTime: expected!.unixTime, ISO: expected!.unixTimeISO });
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -60,12 +60,12 @@ describe('getChineseYearMonthAllDayInfos', () => {
|
||||
}
|
||||
|
||||
const items = line.split('\t');
|
||||
const gregorianDate = items[0];
|
||||
const gregorianDate = items[0] as string;
|
||||
const gregorianDateItems = gregorianDate.split('/');
|
||||
const gregorianYear = parseInt(gregorianDateItems[0], 10);
|
||||
const gregorianMonth = parseInt(gregorianDateItems[1], 10);
|
||||
const chineseDay = items[1];
|
||||
const solarTermName = items.length > 3 ? items[3] : '';
|
||||
const gregorianYear = parseInt(gregorianDateItems[0] as string, 10);
|
||||
const gregorianMonth = parseInt(gregorianDateItems[1] as string, 10);
|
||||
const chineseDay = items[1] as string;
|
||||
const solarTermName = items.length > 3 ? items[3] as string : '';
|
||||
|
||||
if (currentYear > 0 && currentMonth > 0 && (gregorianYear !== currentYear || gregorianMonth !== currentMonth)) {
|
||||
allMonthChineseDays[`${currentYear}-${currentMonth}`] = currentMonthChineseDays;
|
||||
@@ -93,10 +93,10 @@ describe('getChineseYearMonthAllDayInfos', () => {
|
||||
for (const yearMonth in allMonthChineseDays) {
|
||||
test(`returns correct chinese all dates in month for ${yearMonth}`, () => {
|
||||
const [yearStr, monthStr] = yearMonth.split('-');
|
||||
const year = parseInt(yearStr);
|
||||
const month = parseInt(monthStr);
|
||||
const expectedChineseMonthOrDays = allMonthChineseDays[yearMonth];
|
||||
const expectedSolarTermNames = allMonthSolarTermNames[yearMonth];
|
||||
const year = parseInt(yearStr as string);
|
||||
const month = parseInt(monthStr as string);
|
||||
const expectedChineseMonthOrDays = allMonthChineseDays[yearMonth] as string[];
|
||||
const expectedSolarTermNames = allMonthSolarTermNames[yearMonth] as string[];
|
||||
|
||||
const actualChineseDates: ChineseYearMonthDayInfo[] | undefined = getChineseYearMonthAllDayInfos({
|
||||
year: year,
|
||||
@@ -128,13 +128,13 @@ describe('getChineseYearMonthDayInfo', () => {
|
||||
}
|
||||
|
||||
const items = line.split('\t');
|
||||
const gregorianDate = items[0];
|
||||
const gregorianDate = items[0] as string;
|
||||
const gregorianDateItems = gregorianDate.split('/');
|
||||
const gregorianYear = parseInt(gregorianDateItems[0]);
|
||||
const gregorianMonth = parseInt(gregorianDateItems[1]);
|
||||
const gregorianDay = parseInt(gregorianDateItems[2]);
|
||||
const expectedChineseMonthOrDay = items[1];
|
||||
const expectedSolarTermName = items.length > 3 ? items[3] : '';
|
||||
const gregorianYear = parseInt(gregorianDateItems[0] as string);
|
||||
const gregorianMonth = parseInt(gregorianDateItems[1] as string);
|
||||
const gregorianDay = parseInt(gregorianDateItems[2] as string);
|
||||
const expectedChineseMonthOrDay = items[1] as string;
|
||||
const expectedSolarTermName = items.length > 3 ? items[3] as string : '';
|
||||
|
||||
test(`returns correct chinese date for ${gregorianDate}`, () => {
|
||||
const actualChineseDate: ChineseYearMonthDayInfo | undefined = getChineseYearMonthDayInfo({
|
||||
|
||||
@@ -177,9 +177,9 @@ function getSolarTermName(gregorianDate: YearMonthDay, localeData: ChineseCalend
|
||||
const [firstTermDay, firstTermIndex, secondTermDay, secondTermIndex] = getSolarTermDays(gregorianDate.year, gregorianDate.month);
|
||||
|
||||
if (firstTermDay > 0 && firstTermDay === gregorianDate.day) {
|
||||
return localeData.solarTermNames[firstTermIndex];
|
||||
return localeData.solarTermNames[firstTermIndex] ?? '';
|
||||
} else if (secondTermDay > 0 && secondTermDay === gregorianDate.day) {
|
||||
return localeData.solarTermNames[secondTermIndex];
|
||||
return localeData.solarTermNames[secondTermIndex] ?? '';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@@ -317,7 +317,7 @@ function buildChineseYearMonthDayInfo(gregorianDate: YearMonthDay, chineseDate:
|
||||
day: chineseDate.day,
|
||||
displayYear: getChineseNumber(chineseDate.year, localeData),
|
||||
displayMonth: (chineseDate.isLeapMonth ? localeData.leapMonthPrefix : '') + localeData.monthNames[chineseDate.month - 1],
|
||||
displayDay: localeData.dayNames[chineseDate.day - 1],
|
||||
displayDay: localeData.dayNames[chineseDate.day - 1] ?? '',
|
||||
isLeapMonth: chineseDate.isLeapMonth,
|
||||
solarTermName: getSolarTermName(gregorianDate, localeData)
|
||||
};
|
||||
|
||||
+47
-107
@@ -1,3 +1,4 @@
|
||||
import { itemAndIndex, reversed, entries, keys, values } from '@/core/base.ts';
|
||||
import { type LocalizedPresetCategory, CategoryType } from '@/core/category.ts';
|
||||
import { TransactionType } from '@/core/transaction.ts';
|
||||
import {
|
||||
@@ -34,8 +35,7 @@ export function categoryTypeToTransactionType(categoryType: CategoryType): Trans
|
||||
export function localizedPresetCategoryToTransactionCategoryCreateWithSubCategorys(presetCategory: LocalizedPresetCategory): TransactionCategoryCreateWithSubCategories {
|
||||
const subCategories: TransactionCategoryCreateRequest[] = [];
|
||||
|
||||
for (let i = 0; i < presetCategory.subCategories.length; i++) {
|
||||
const subPresetCategory = presetCategory.subCategories[i];
|
||||
for (const subPresetCategory of presetCategory.subCategories) {
|
||||
const subCategory: TransactionCategoryCreateRequest = {
|
||||
name: subPresetCategory.name,
|
||||
type: subPresetCategory.type,
|
||||
@@ -63,8 +63,7 @@ export function localizedPresetCategoryToTransactionCategoryCreateWithSubCategor
|
||||
export function localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories(presetCategories: LocalizedPresetCategory[]): TransactionCategoryCreateWithSubCategories[] {
|
||||
const categories: TransactionCategoryCreateWithSubCategories[] = [];
|
||||
|
||||
for (let i = 0; i < presetCategories.length; i++) {
|
||||
const presetCategory = presetCategories[i];
|
||||
for (const presetCategory of presetCategories) {
|
||||
const categoryWithSubCategories = localizedPresetCategoryToTransactionCategoryCreateWithSubCategorys(presetCategory);
|
||||
categories.push(categoryWithSubCategories);
|
||||
}
|
||||
@@ -79,12 +78,9 @@ export function getSecondaryTransactionMapByName(allCategories: TransactionCateg
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (let i = 0; i < allCategories.length; i++) {
|
||||
const category = allCategories[i];
|
||||
|
||||
for (const category of allCategories) {
|
||||
if (category.subCategories) {
|
||||
for (let j = 0; j < category.subCategories.length; j++) {
|
||||
const subCategory = category.subCategories[j];
|
||||
for (const subCategory of category.subCategories) {
|
||||
ret[subCategory.name] = subCategory;
|
||||
}
|
||||
}
|
||||
@@ -93,22 +89,21 @@ export function getSecondaryTransactionMapByName(allCategories: TransactionCateg
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function getTransactionPrimaryCategoryName(categoryId: string | null | undefined, allCategories: TransactionCategory[]): string {
|
||||
export function getTransactionPrimaryCategoryName(categoryId: string | null | undefined, allCategories?: TransactionCategory[]): string {
|
||||
if (!allCategories) {
|
||||
return '';
|
||||
}
|
||||
|
||||
for (let i = 0; i < allCategories.length; i++) {
|
||||
const subCategoryList = allCategories[i].subCategories;
|
||||
for (const category of allCategories) {
|
||||
const subCategoryList = category.subCategories;
|
||||
|
||||
if (!subCategoryList) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let j = 0; j < subCategoryList.length; j++) {
|
||||
const subCategory = subCategoryList[j];
|
||||
for (const subCategory of subCategoryList) {
|
||||
if (subCategory.id === categoryId) {
|
||||
return allCategories[i].name;
|
||||
return category.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,20 +111,19 @@ export function getTransactionPrimaryCategoryName(categoryId: string | null | un
|
||||
return '';
|
||||
}
|
||||
|
||||
export function getTransactionSecondaryCategoryName(categoryId: string | null | undefined, allCategories: TransactionCategory[]): string {
|
||||
export function getTransactionSecondaryCategoryName(categoryId: string | null | undefined, allCategories?: TransactionCategory[]): string {
|
||||
if (!allCategories) {
|
||||
return '';
|
||||
}
|
||||
|
||||
for (let i = 0; i < allCategories.length; i++) {
|
||||
const subCategoryList = allCategories[i].subCategories;
|
||||
for (const category of allCategories) {
|
||||
const subCategoryList = category.subCategories;
|
||||
|
||||
if (!subCategoryList) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let j = 0; j < subCategoryList.length; j++) {
|
||||
const subCategory = subCategoryList[j];
|
||||
for (const subCategory of subCategoryList) {
|
||||
if (subCategory.id === categoryId) {
|
||||
return subCategory.name;
|
||||
}
|
||||
@@ -148,9 +142,7 @@ export function allTransactionCategoriesWithVisibleCount(allTransactionCategorie
|
||||
|
||||
const allCategoryTypes = [ CategoryType.Income, CategoryType.Expense, CategoryType.Transfer ];
|
||||
|
||||
for (let i = 0; i < allCategoryTypes.length; i++) {
|
||||
const categoryType = allCategoryTypes[i];
|
||||
|
||||
for (const categoryType of allCategoryTypes) {
|
||||
if (!allTransactionCategories[categoryType]) {
|
||||
continue;
|
||||
}
|
||||
@@ -166,14 +158,12 @@ export function allTransactionCategoriesWithVisibleCount(allTransactionCategorie
|
||||
let allVisibleCategoryCount = 0;
|
||||
let firstVisibleCategoryIndex = -1;
|
||||
|
||||
for (let j = 0; j < allCategories.length; j++) {
|
||||
const category = allCategories[j];
|
||||
|
||||
for (const [category, cagtegoryIndex] of itemAndIndex(allCategories)) {
|
||||
if (!category.hidden) {
|
||||
allVisibleCategoryCount++;
|
||||
|
||||
if (firstVisibleCategoryIndex === -1) {
|
||||
firstVisibleCategoryIndex = j;
|
||||
firstVisibleCategoryIndex = cagtegoryIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,14 +171,12 @@ export function allTransactionCategoriesWithVisibleCount(allTransactionCategorie
|
||||
let visibleSubCategoryCount = 0;
|
||||
let firstVisibleSubCategoryIndex = -1;
|
||||
|
||||
for (let k = 0; k < category.subCategories.length; k++) {
|
||||
const subCategory = category.subCategories[k];
|
||||
|
||||
for (const [subCategory, subCategoryIndex] of itemAndIndex(category.subCategories)) {
|
||||
if (!subCategory.hidden) {
|
||||
visibleSubCategoryCount++;
|
||||
|
||||
if (firstVisibleSubCategoryIndex === -1) {
|
||||
firstVisibleSubCategoryIndex = k;
|
||||
firstVisibleSubCategoryIndex = subCategoryIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,9 +211,7 @@ export function allVisiblePrimaryTransactionCategoriesByType(allTransactionCateg
|
||||
return visibleCategories;
|
||||
}
|
||||
|
||||
for (let i = 0; i < allCategories.length; i++) {
|
||||
const category = allCategories[i];
|
||||
|
||||
for (const category of allCategories) {
|
||||
if (category.hidden) {
|
||||
continue;
|
||||
}
|
||||
@@ -243,13 +229,7 @@ export function getFinalCategoryIdsByFilteredCategoryIds(allTransactionCategorie
|
||||
return finalCategoryIds;
|
||||
}
|
||||
|
||||
for (const categoryId in allTransactionCategoriesMap) {
|
||||
if (!Object.prototype.hasOwnProperty.call(allTransactionCategoriesMap, categoryId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const category = allTransactionCategoriesMap[categoryId];
|
||||
|
||||
for (const category of values(allTransactionCategoriesMap)) {
|
||||
if (filteredCategoryIds && !isCategoryOrSubCategoriesAllChecked(category, filteredCategoryIds)) {
|
||||
continue;
|
||||
}
|
||||
@@ -269,9 +249,7 @@ export function isSubCategoryIdAvailable(categories: TransactionCategory[], cate
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < categories.length; i++) {
|
||||
const primaryCategory = categories[i];
|
||||
|
||||
for (const primaryCategory of categories) {
|
||||
if (primaryCategory.hidden) {
|
||||
continue;
|
||||
}
|
||||
@@ -282,9 +260,7 @@ export function isSubCategoryIdAvailable(categories: TransactionCategory[], cate
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let j = 0; j < subCategoryList.length; j++) {
|
||||
const secondaryCategory = subCategoryList[j];
|
||||
|
||||
for (const secondaryCategory of subCategoryList) {
|
||||
if (secondaryCategory.hidden) {
|
||||
continue;
|
||||
}
|
||||
@@ -303,9 +279,7 @@ export function getFirstAvailableCategoryId(categories: TransactionCategory[]):
|
||||
return '';
|
||||
}
|
||||
|
||||
for (let i = 0; i < categories.length; i++) {
|
||||
const primaryCategory = categories[i];
|
||||
|
||||
for (const primaryCategory of categories) {
|
||||
if (primaryCategory.hidden) {
|
||||
continue;
|
||||
}
|
||||
@@ -316,9 +290,7 @@ export function getFirstAvailableCategoryId(categories: TransactionCategory[]):
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let j = 0; j < subCategoryList.length; j++) {
|
||||
const secondaryCategory = subCategoryList[j];
|
||||
|
||||
for (const secondaryCategory of subCategoryList) {
|
||||
if (secondaryCategory.hidden) {
|
||||
continue;
|
||||
}
|
||||
@@ -335,9 +307,7 @@ export function getFirstAvailableSubCategoryId(categories: TransactionCategory[]
|
||||
return '';
|
||||
}
|
||||
|
||||
for (let i = 0; i < categories.length; i++) {
|
||||
const primaryCategory = categories[i];
|
||||
|
||||
for (const primaryCategory of categories) {
|
||||
if (primaryCategory.hidden || primaryCategory.id !== categoryId) {
|
||||
continue;
|
||||
}
|
||||
@@ -348,9 +318,7 @@ export function getFirstAvailableSubCategoryId(categories: TransactionCategory[]
|
||||
return '';
|
||||
}
|
||||
|
||||
for (let j = 0; j < subCategoryList.length; j++) {
|
||||
const secondaryCategory = subCategoryList[j];
|
||||
|
||||
for (const secondaryCategory of subCategoryList) {
|
||||
if (secondaryCategory.hidden) {
|
||||
continue;
|
||||
}
|
||||
@@ -365,8 +333,8 @@ export function getFirstAvailableSubCategoryId(categories: TransactionCategory[]
|
||||
}
|
||||
|
||||
export function isNoAvailableCategory(categories: TransactionCategory[], showHidden: boolean): boolean {
|
||||
for (let i = 0; i < categories.length; i++) {
|
||||
if (showHidden || !categories[i].hidden) {
|
||||
for (const category of categories) {
|
||||
if (showHidden || !category.hidden) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -377,8 +345,8 @@ export function isNoAvailableCategory(categories: TransactionCategory[], showHid
|
||||
export function getAvailableCategoryCount(categories: TransactionCategory[], showHidden: boolean): number {
|
||||
let count = 0;
|
||||
|
||||
for (let i = 0; i < categories.length; i++) {
|
||||
if (showHidden || !categories[i].hidden) {
|
||||
for (const category of categories) {
|
||||
if (showHidden || !category.hidden) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -387,9 +355,9 @@ export function getAvailableCategoryCount(categories: TransactionCategory[], sho
|
||||
}
|
||||
|
||||
export function getFirstShowingId(categories: TransactionCategory[], showHidden: boolean): string | null {
|
||||
for (let i = 0; i < categories.length; i++) {
|
||||
if (showHidden || !categories[i].hidden) {
|
||||
return categories[i].id;
|
||||
for (const category of categories) {
|
||||
if (showHidden || !category.hidden) {
|
||||
return category.id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,9 +365,9 @@ export function getFirstShowingId(categories: TransactionCategory[], showHidden:
|
||||
}
|
||||
|
||||
export function getLastShowingId(categories: TransactionCategory[], showHidden: boolean): string | null {
|
||||
for (let i = categories.length - 1; i >= 0; i--) {
|
||||
if (showHidden || !categories[i].hidden) {
|
||||
return categories[i].id;
|
||||
for (const category of reversed(categories)) {
|
||||
if (showHidden || !category.hidden) {
|
||||
return category.id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,13 +375,7 @@ export function getLastShowingId(categories: TransactionCategory[], showHidden:
|
||||
}
|
||||
|
||||
export function containsAnyAvailableCategory(allTransactionCategories: Record<number, TransactionCategoriesWithVisibleCount>, showHidden: boolean): boolean {
|
||||
for (const type in allTransactionCategories) {
|
||||
if (!Object.prototype.hasOwnProperty.call(allTransactionCategories, type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const categoryType = allTransactionCategories[type];
|
||||
|
||||
for (const categoryType of values(allTransactionCategories)) {
|
||||
if (showHidden) {
|
||||
if (categoryType.allCategories && categoryType.allCategories.length > 0) {
|
||||
return true;
|
||||
@@ -431,13 +393,7 @@ export function containsAnyAvailableCategory(allTransactionCategories: Record<nu
|
||||
export function containsAvailableCategory(allTransactionCategories: Record<number, TransactionCategoriesWithVisibleCount>, showHidden: boolean): Record<number, boolean> {
|
||||
const result: Record<number, boolean> = {};
|
||||
|
||||
for (const type in allTransactionCategories) {
|
||||
if (!Object.prototype.hasOwnProperty.call(allTransactionCategories, type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const categoryType = allTransactionCategories[type];
|
||||
|
||||
for (const [type, categoryType] of entries(allTransactionCategories)) {
|
||||
if (showHidden) {
|
||||
result[type] = categoryType.allCategories && categoryType.allCategories.length > 0;
|
||||
} else {
|
||||
@@ -448,23 +404,18 @@ export function containsAvailableCategory(allTransactionCategories: Record<numbe
|
||||
return result;
|
||||
}
|
||||
|
||||
export function selectAllSubCategories(filterCategoryIds: Record<string, boolean>, category: TransactionCategory, value: boolean): void {
|
||||
export function selectAllSubCategories(filterCategoryIds: Record<string, boolean>, value: boolean, category?: TransactionCategory): void {
|
||||
if (!category || !category.subCategories || !category.subCategories.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < category.subCategories.length; i++) {
|
||||
const subCategory = category.subCategories[i];
|
||||
for (const subCategory of category.subCategories) {
|
||||
filterCategoryIds[subCategory.id] = value;
|
||||
}
|
||||
}
|
||||
|
||||
export function selectAll(filterCategoryIds: Record<string, boolean>, allTransactionCategoriesMap: Record<string, TransactionCategory>): void {
|
||||
for (const categoryId in filterCategoryIds) {
|
||||
if (!Object.prototype.hasOwnProperty.call(filterCategoryIds, categoryId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const categoryId of keys(filterCategoryIds)) {
|
||||
const category = allTransactionCategoriesMap[categoryId];
|
||||
|
||||
if (category) {
|
||||
@@ -474,11 +425,7 @@ export function selectAll(filterCategoryIds: Record<string, boolean>, allTransac
|
||||
}
|
||||
|
||||
export function selectNone(filterCategoryIds: Record<string, boolean>, allTransactionCategoriesMap: Record<string, TransactionCategory>): void {
|
||||
for (const categoryId in filterCategoryIds) {
|
||||
if (!Object.prototype.hasOwnProperty.call(filterCategoryIds, categoryId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const categoryId of keys(filterCategoryIds)) {
|
||||
const category = allTransactionCategoriesMap[categoryId];
|
||||
|
||||
if (category) {
|
||||
@@ -488,11 +435,7 @@ export function selectNone(filterCategoryIds: Record<string, boolean>, allTransa
|
||||
}
|
||||
|
||||
export function selectInvert(filterCategoryIds: Record<string, boolean>, allTransactionCategoriesMap: Record<string, TransactionCategory>): void {
|
||||
for (const categoryId in filterCategoryIds) {
|
||||
if (!Object.prototype.hasOwnProperty.call(filterCategoryIds, categoryId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const categoryId of keys(filterCategoryIds)) {
|
||||
const category = allTransactionCategoriesMap[categoryId];
|
||||
|
||||
if (category) {
|
||||
@@ -506,8 +449,7 @@ export function isCategoryOrSubCategoriesAllChecked(category: TransactionCategor
|
||||
return !filterCategoryIds[category.id];
|
||||
}
|
||||
|
||||
for (let i = 0; i < category.subCategories.length; i++) {
|
||||
const subCategory = category.subCategories[i];
|
||||
for (const subCategory of category.subCategories) {
|
||||
if (filterCategoryIds[subCategory.id]) {
|
||||
return false;
|
||||
}
|
||||
@@ -521,8 +463,7 @@ export function isSubCategoriesAllChecked(category: TransactionCategory, filterC
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < category.subCategories.length; i++) {
|
||||
const subCategory = category.subCategories[i];
|
||||
for (const subCategory of category.subCategories) {
|
||||
if (filterCategoryIds[subCategory.id]) {
|
||||
return false;
|
||||
}
|
||||
@@ -538,8 +479,7 @@ export function isSubCategoriesHasButNotAllChecked(category: TransactionCategory
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < category.subCategories.length; i++) {
|
||||
const subCategory = category.subCategories[i];
|
||||
for (const subCategory of category.subCategories) {
|
||||
if (!filterCategoryIds[subCategory.id]) {
|
||||
checkedCount++;
|
||||
}
|
||||
|
||||
+38
-92
@@ -1,3 +1,4 @@
|
||||
import { keys, keysIfValueEquals, values } from '@/core/base.ts';
|
||||
import type { NameValue, TypeAndName, TypeAndDisplayName} from '@/core/base.ts';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
@@ -48,7 +49,7 @@ export function isYearMonth(val: unknown): val is string {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!parseInt(items[0]) && !!parseInt(items[1]);
|
||||
return !!parseInt(items[0] as string) && !!parseInt(items[1] as string);
|
||||
}
|
||||
|
||||
export function isEquals(obj1: unknown, obj2: unknown): boolean {
|
||||
@@ -82,13 +83,13 @@ export function isEquals(obj1: unknown, obj2: unknown): boolean {
|
||||
const keyExistsMap2 = new Map<string, boolean>();
|
||||
|
||||
for (let i = 0; i < keys2.length; i++) {
|
||||
const key = keys2[i];
|
||||
const key = keys2[i] as string;
|
||||
|
||||
keyExistsMap2.set(key, true);
|
||||
}
|
||||
|
||||
for (let i = 0; i < keys1.length; i++) {
|
||||
const key = keys1[i];
|
||||
const key = keys1[i] as string;
|
||||
|
||||
if (!keyExistsMap2.get(key)) {
|
||||
return false;
|
||||
@@ -117,7 +118,7 @@ export function isYearMonthEquals(val1: unknown, val2: unknown): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (!!parseInt(items1[0]) && !!parseInt(items1[1])) && (parseInt(items1[0]) === parseInt(items2[0])) && (parseInt(items1[1]) === parseInt(items2[1]));
|
||||
return (!!parseInt(items1[0] as string) && !!parseInt(items1[1] as string)) && (parseInt(items1[0] as string) === parseInt(items2[0] as string)) && (parseInt(items1[1] as string) === parseInt(items2[1] as string));
|
||||
}
|
||||
|
||||
export function isArray1SubsetOfArray2<T>(array1: T[], array2: T[]): boolean {
|
||||
@@ -128,11 +129,11 @@ export function isArray1SubsetOfArray2<T>(array1: T[], array2: T[]): boolean {
|
||||
const array2ValuesMap: Map<T, boolean> = new Map<T, boolean>();
|
||||
|
||||
for (let i = 0; i < array2.length; i++) {
|
||||
array2ValuesMap.set(array2[i], true);
|
||||
array2ValuesMap.set(array2[i] as T, true);
|
||||
}
|
||||
|
||||
for (let i = 0; i < array1.length; i++) {
|
||||
if (!array2ValuesMap.get(array1[i])) {
|
||||
if (!array2ValuesMap.get(array1[i] as T)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -145,11 +146,7 @@ export function isObjectEmpty(obj: object): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const field in obj) {
|
||||
if (!Object.prototype.hasOwnProperty.call(obj, field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const _ of keys(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -183,11 +180,8 @@ export function getObjectOwnFieldCount(object: object): number {
|
||||
return count;
|
||||
}
|
||||
|
||||
for (const field in object) {
|
||||
if (!Object.prototype.hasOwnProperty.call(object, field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
for (const _ of keys(object)) {
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -251,26 +245,22 @@ export function getFirstVisibleItem<T>(items: Record<string, T>[] | Record<strin
|
||||
if (isArray(items) && items.length > 0) {
|
||||
const arr = items as Record<string, T>[];
|
||||
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (hiddenField && arr[i][hiddenField]) {
|
||||
for (const item of arr) {
|
||||
if (hiddenField && item[hiddenField]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return arr[i];
|
||||
return item;
|
||||
}
|
||||
} else if (isObject(items)) {
|
||||
const obj = items as Record<string, Record<string, T>>;
|
||||
|
||||
for (const field in obj) {
|
||||
if (!Object.prototype.hasOwnProperty.call(obj, field)) {
|
||||
for (const item of values(obj)) {
|
||||
if (hiddenField && item[hiddenField]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hiddenField && obj[field][hiddenField]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return obj[field];
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,9 +271,7 @@ export function getItemByKeyValue<T>(src: Record<string, T>[] | Record<string, R
|
||||
if (isArray(src)) {
|
||||
const arr = src as Record<string, T>[];
|
||||
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const item = arr[i];
|
||||
|
||||
for (const item of arr) {
|
||||
if (item[keyField] === value) {
|
||||
return item;
|
||||
}
|
||||
@@ -291,13 +279,7 @@ export function getItemByKeyValue<T>(src: Record<string, T>[] | Record<string, R
|
||||
} else if (isObject(src)) {
|
||||
const obj = src as Record<string, Record<string, T>>;
|
||||
|
||||
for (const field in obj) {
|
||||
if (!Object.prototype.hasOwnProperty.call(src, field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const item = obj[field];
|
||||
|
||||
for (const item of values(obj)) {
|
||||
if (item[keyField] === value) {
|
||||
return item;
|
||||
}
|
||||
@@ -342,9 +324,7 @@ export function getNameByKeyValue<V, N>(src: Record<string, N | V>[] | Record<st
|
||||
const arr = src as Record<string, N | V>[];
|
||||
|
||||
if (keyField) {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const option = arr[i];
|
||||
|
||||
for (const option of arr) {
|
||||
if (option[keyField] === value) {
|
||||
return option[nameField] as N;
|
||||
}
|
||||
@@ -362,13 +342,7 @@ export function getNameByKeyValue<V, N>(src: Record<string, N | V>[] | Record<st
|
||||
const obj = src as Record<string, Record<string, N | V>>;
|
||||
|
||||
if (keyField) {
|
||||
for (const key in obj) {
|
||||
if (!Object.prototype.hasOwnProperty.call(src, key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const option = obj[key];
|
||||
|
||||
for (const option of values(obj)) {
|
||||
if (option[keyField] === value) {
|
||||
return option[nameField] as N;
|
||||
}
|
||||
@@ -392,8 +366,8 @@ export function arrayContainsFieldValue<T>(array: Record<string, T>[], fieldName
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i][fieldName] === value) {
|
||||
for (const item of array) {
|
||||
if (item[fieldName] === value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -404,11 +378,7 @@ export function arrayContainsFieldValue<T>(array: Record<string, T>[], fieldName
|
||||
export function objectFieldToArrayItem(object: object): string[] {
|
||||
const ret: string[] = [];
|
||||
|
||||
for (const field in object) {
|
||||
if (!Object.prototype.hasOwnProperty.call(object, field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const field of keys(object)) {
|
||||
ret.push(field);
|
||||
}
|
||||
|
||||
@@ -418,14 +388,8 @@ export function objectFieldToArrayItem(object: object): string[] {
|
||||
export function objectFieldWithValueToArrayItem<T>(object: Record<string, T>, value: T): string[] {
|
||||
const ret: string[] = [];
|
||||
|
||||
for (const field in object) {
|
||||
if (!Object.prototype.hasOwnProperty.call(object, field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (object[field] === value) {
|
||||
ret.push(field);
|
||||
}
|
||||
for (const field of keysIfValueEquals(object, value)) {
|
||||
ret.push(field);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -434,8 +398,8 @@ export function objectFieldWithValueToArrayItem<T>(object: Record<string, T>, va
|
||||
export function arrayItemToObjectField<T>(array: string[], value: T): Record<string, T> {
|
||||
const ret: Record<string, T> = {};
|
||||
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
ret[array[i]] = value;
|
||||
for (const item of array) {
|
||||
ret[item] = value;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -450,9 +414,9 @@ export function splitItemsToMap(str: string | undefined | null, separator: strin
|
||||
|
||||
const items = str.split(separator);
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (items[i]) {
|
||||
ret[items[i]] = true;
|
||||
for (const item of items) {
|
||||
if (item) {
|
||||
ret[item] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,15 +443,9 @@ export function countSplitItems(str: string | undefined | null, separator: strin
|
||||
export function categorizedArrayToPlainArray<T>(object: Record<string, T[]>): T[] {
|
||||
const ret: T[] = [];
|
||||
|
||||
for (const field in object) {
|
||||
if (!Object.prototype.hasOwnProperty.call(object, field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const array = object[field];
|
||||
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
ret.push(array[i]);
|
||||
for (const array of values(object)) {
|
||||
for (const item of array) {
|
||||
ret.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,11 +453,7 @@ export function categorizedArrayToPlainArray<T>(object: Record<string, T[]>): T[
|
||||
}
|
||||
|
||||
export function selectAll(filterItemIds: Record<string, boolean>, allItemsMap: { [key: string]: { id: string } }): void {
|
||||
for (const itemId in filterItemIds) {
|
||||
if (!Object.prototype.hasOwnProperty.call(filterItemIds, itemId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const itemId of keys(filterItemIds)) {
|
||||
const item = allItemsMap[itemId];
|
||||
|
||||
if (item) {
|
||||
@@ -509,11 +463,7 @@ export function selectAll(filterItemIds: Record<string, boolean>, allItemsMap: {
|
||||
}
|
||||
|
||||
export function selectNone(filterItemIds: Record<string, boolean>, allItemsMap: { [key: string]: { id: string } }): void {
|
||||
for (const itemId in filterItemIds) {
|
||||
if (!Object.prototype.hasOwnProperty.call(filterItemIds, itemId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const itemId of keys(filterItemIds)) {
|
||||
const item = allItemsMap[itemId];
|
||||
|
||||
if (item) {
|
||||
@@ -523,11 +473,7 @@ export function selectNone(filterItemIds: Record<string, boolean>, allItemsMap:
|
||||
}
|
||||
|
||||
export function selectInvert(filterItemIds: Record<string, boolean>, allItemsMap: { [key: string]: { id: string } }): void {
|
||||
for (const itemId in filterItemIds) {
|
||||
if (!Object.prototype.hasOwnProperty.call(filterItemIds, itemId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const itemId of keys(filterItemIds)) {
|
||||
const item = allItemsMap[itemId];
|
||||
|
||||
if (item) {
|
||||
@@ -610,11 +556,11 @@ export function arrangeArrayWithNewStartIndex<T>(array: T[], startIndex: number)
|
||||
const newArray: T[] = [];
|
||||
|
||||
for (let i = startIndex; i < array.length; i++) {
|
||||
newArray.push(array[i]);
|
||||
newArray.push(array[i] as T);
|
||||
}
|
||||
|
||||
for (let i = 0; i < startIndex; i++) {
|
||||
newArray.push(array[i]);
|
||||
newArray.push(array[i] as T);
|
||||
}
|
||||
|
||||
return newArray;
|
||||
|
||||
+17
-18
@@ -3,6 +3,9 @@ import { type unitOfTime } from 'moment/moment';
|
||||
|
||||
import jalaali, { type JalaaliDateObject } from 'jalaali-js';
|
||||
|
||||
import {
|
||||
itemAndIndex
|
||||
} from '@/core/base.ts';
|
||||
import {
|
||||
type ChineseCalendarLocaleData,
|
||||
CalendarType
|
||||
@@ -426,8 +429,8 @@ export function getYear0BasedMonthObjectFromString(yearMonth: TextualYearMonth |
|
||||
return null;
|
||||
}
|
||||
|
||||
const year = parseInt(items[0]);
|
||||
const month0base = parseInt(items[1]) - 1;
|
||||
const year = parseInt(items[0] as string);
|
||||
const month0base = parseInt(items[1] as string) - 1;
|
||||
|
||||
if (!isYear0BasedMonthValid(year, month0base)) {
|
||||
return null;
|
||||
@@ -581,9 +584,9 @@ export function getLocalDateFromYearDashMonthDashDay(date: TextualYearMonthDay):
|
||||
return null;
|
||||
}
|
||||
|
||||
const year = parseInt(items[0]);
|
||||
const month = parseInt(items[1]);
|
||||
const day = parseInt(items[2]);
|
||||
const year = parseInt(items[0] as string);
|
||||
const month = parseInt(items[1] as string);
|
||||
const day = parseInt(items[2] as string);
|
||||
|
||||
if (!isNumber(year) || !isNumber(month) || !isNumber(day)) {
|
||||
return null;
|
||||
@@ -983,8 +986,8 @@ export function getAllDaysStartAndEndUnixTimes(startUnixTime: number, endUnixTim
|
||||
}
|
||||
|
||||
export function getDateTimeFormatType<T extends DateFormat | TimeFormat>(allFormatMap: Record<string, T>, allFormatArray: T[], formatTypeValue: number, languageDefaultTypeName: string, systemDefaultFormatType: T): T {
|
||||
if (formatTypeValue > LANGUAGE_DEFAULT_DATE_TIME_FORMAT_VALUE && allFormatArray[formatTypeValue - 1] && allFormatArray[formatTypeValue - 1].key) {
|
||||
return allFormatArray[formatTypeValue - 1];
|
||||
if (formatTypeValue > LANGUAGE_DEFAULT_DATE_TIME_FORMAT_VALUE && allFormatArray[formatTypeValue - 1] && allFormatArray[formatTypeValue - 1]!.key) {
|
||||
return allFormatArray[formatTypeValue - 1] as T;
|
||||
} else if (formatTypeValue === LANGUAGE_DEFAULT_DATE_TIME_FORMAT_VALUE && allFormatMap[languageDefaultTypeName] && allFormatMap[languageDefaultTypeName].key) {
|
||||
return allFormatMap[languageDefaultTypeName];
|
||||
} else {
|
||||
@@ -1079,9 +1082,7 @@ export function getDateTypeByDateRange(minTime: number, maxTime: number, firstDa
|
||||
const allDateRanges = DateRange.values();
|
||||
let newDateType = DateRange.Custom.type;
|
||||
|
||||
for (let i = 0; i < allDateRanges.length; i++) {
|
||||
const dateRange = allDateRanges[i];
|
||||
|
||||
for (const dateRange of allDateRanges) {
|
||||
if (!dateRange.isAvailableForScene(scene)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1264,9 +1265,9 @@ export function getRecentMonthDateRanges(monthCount: number): RecentMonthDateRan
|
||||
}
|
||||
|
||||
export function getRecentDateRangeIndexByDateType(allRecentMonthDateRanges: LocalizedRecentMonthDateRange[], dateType: number): number {
|
||||
for (let i = 0; i < allRecentMonthDateRanges.length; i++) {
|
||||
if (!allRecentMonthDateRanges[i].isPreset && allRecentMonthDateRanges[i].dateType === dateType) {
|
||||
return i;
|
||||
for (const [recentDateRange, index] of itemAndIndex(allRecentMonthDateRanges)) {
|
||||
if (!recentDateRange.isPreset && recentDateRange.dateType === dateType) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1292,11 +1293,9 @@ export function getRecentDateRangeIndex(allRecentMonthDateRanges: LocalizedRecen
|
||||
};
|
||||
}
|
||||
|
||||
for (let i = 0; i < allRecentMonthDateRanges.length; i++) {
|
||||
const recentDateRange = allRecentMonthDateRanges[i];
|
||||
|
||||
for (const [recentDateRange, index] of itemAndIndex(allRecentMonthDateRanges)) {
|
||||
if (recentDateRange.isPreset && recentDateRange.minTime === dateRange.minTime && recentDateRange.maxTime === dateRange.maxTime) {
|
||||
return i;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1356,7 +1355,7 @@ export function getValidMonthDayOrCurrentDayShortDate(unixTime: number, currentS
|
||||
const yearMonthDay = currentShortDate.split('-');
|
||||
|
||||
if (yearMonthDay.length === 3) {
|
||||
const currentDay = parseInt(yearMonthDay[2]);
|
||||
const currentDay = parseInt(yearMonthDay[2] as string);
|
||||
|
||||
if (currentDay < monthLastTime.date()) {
|
||||
return MomentDateTime.of(monthLastTime.set({ date: currentDay })).getGregorianCalendarYearDashMonthDashDay();
|
||||
|
||||
+3
-5
@@ -8,7 +8,7 @@ export function getFileExtension(filename: string): string {
|
||||
}
|
||||
|
||||
const parts = filename.split('.');
|
||||
return parts[parts.length - 1];
|
||||
return parts[parts.length - 1] as string;
|
||||
}
|
||||
|
||||
export function findExtensionByType(items: ImportFileTypeAndExtensions[] | undefined, type: string): string | undefined {
|
||||
@@ -33,10 +33,8 @@ export function isFileExtensionSupported(filename: string, supportedExtensions:
|
||||
const supportedExtensionsArray = supportedExtensions.split(',');
|
||||
const fileExtension = getFileExtension(filename).toLowerCase();
|
||||
|
||||
for (let i = 0; i < supportedExtensionsArray.length; i++) {
|
||||
const supportedExtension = getFileExtension(supportedExtensionsArray[i]).toLowerCase();
|
||||
|
||||
if (supportedExtension === fileExtension) {
|
||||
for (const supportedExtension of supportedExtensionsArray) {
|
||||
if (getFileExtension(supportedExtension).toLowerCase() === fileExtension) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-9
@@ -1,24 +1,19 @@
|
||||
import { entries } from '@/core/base.ts';
|
||||
import type { IconInfo, IconInfoWithId } from '@/core/icon.ts';
|
||||
|
||||
export function getIconsInRows(allIconInfos: Record<string, IconInfo>, itemPerRow: number): IconInfoWithId[][] {
|
||||
const ret: IconInfoWithId[][] = [];
|
||||
let rowCount = 0;
|
||||
|
||||
for (const iconInfoId in allIconInfos) {
|
||||
if (!Object.prototype.hasOwnProperty.call(allIconInfos, iconInfoId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const iconInfo = allIconInfos[iconInfoId];
|
||||
|
||||
for (const [iconInfoId, iconInfo] of entries(allIconInfos)) {
|
||||
if (!ret[rowCount]) {
|
||||
ret[rowCount] = [];
|
||||
} else if (ret[rowCount] && ret[rowCount].length >= itemPerRow) {
|
||||
} else if (ret[rowCount] && ret[rowCount]!.length >= itemPerRow) {
|
||||
rowCount++;
|
||||
ret[rowCount] = [];
|
||||
}
|
||||
|
||||
ret[rowCount].push({
|
||||
ret[rowCount]!.push({
|
||||
id: iconInfoId,
|
||||
icon: iconInfo.icon
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ export function sortStatisticsItems<T extends SortableTransactionStatisticDataIt
|
||||
items.sort(function (data1, data2) {
|
||||
for (let i = 0; i < Math.min(data1.displayOrders.length, data2.displayOrders.length); i++) {
|
||||
if (data1.displayOrders[i] !== data2.displayOrders[i]) {
|
||||
return data1.displayOrders[i] - data2.displayOrders[i]; // asc
|
||||
return (data1.displayOrders[i] as number) - (data2.displayOrders[i] as number); // asc
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +52,8 @@ export function getAllDateRangesFromItems<T extends Year1BasedMonth>(items: Year
|
||||
if ((!startYearMonth || !endYearMonth) && items && items.length) {
|
||||
let minYear = Number.MAX_SAFE_INTEGER, minMonth = Number.MAX_SAFE_INTEGER, maxYear = 0, maxMonth = 0;
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
|
||||
for (let j = 0; j < item.items.length; j++) {
|
||||
const dataItem = item.items[j];
|
||||
|
||||
for (const item of items) {
|
||||
for (const dataItem of item.items) {
|
||||
if (dataItem.year < minYear || (dataItem.year === minYear && dataItem.month1base < minMonth)) {
|
||||
minYear = dataItem.year;
|
||||
minMonth = dataItem.month1base;
|
||||
|
||||
@@ -59,9 +59,7 @@ export function setExpenseAndIncomeAmountColor(expenseAmountColorType: number, i
|
||||
|
||||
const allPresetAmountColors = PresetAmountColor.values();
|
||||
|
||||
for (let i = 0; i < allPresetAmountColors.length; i++) {
|
||||
const amountColor = allPresetAmountColors[i];
|
||||
|
||||
for (const amountColor of allPresetAmountColors) {
|
||||
if (amountColor.type === expenseAmountColor.type) {
|
||||
if (!htmlElement.classList.contains(amountColor.expenseClassName)) {
|
||||
htmlElement.classList.add(amountColor.expenseClassName);
|
||||
@@ -97,8 +95,8 @@ export function openTextFileContent({ allowedExtensions }: { allowedExtensions:
|
||||
fileInput.onchange = (event) => {
|
||||
const el = event.target as HTMLInputElement;
|
||||
|
||||
if (el.files && el.files.length > 0) {
|
||||
const file = el.files[0];
|
||||
if (el.files && el.files.length > 0 && el.files[0]) {
|
||||
const file = el.files[0] as File;
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = (e) => {
|
||||
@@ -146,8 +144,7 @@ export function clearBrowserCaches(): Promise<void> {
|
||||
window.caches.keys().then(cacheNames => {
|
||||
const promises = [];
|
||||
|
||||
for (let i = 0; i < cacheNames.length; i++) {
|
||||
const cacheName = cacheNames[i];
|
||||
for (const cacheName of cacheNames) {
|
||||
promises.push(window.caches.delete(cacheName).then(success => {
|
||||
if (success) {
|
||||
logger.info(`cache "${cacheName}" cleared successfully`);
|
||||
|
||||
@@ -74,9 +74,7 @@ export function setAppFontSize(type: number): void {
|
||||
const htmlElement = f7.$('html');
|
||||
const allFontSizes = FontSize.values();
|
||||
|
||||
for (let i = 0; i < allFontSizes.length; i++) {
|
||||
const fontSizeType = allFontSizes[i];
|
||||
|
||||
for (const fontSizeType of allFontSizes) {
|
||||
if (fontSizeType.type === type) {
|
||||
if (!htmlElement.hasClass(fontSizeType.className)) {
|
||||
htmlElement.addClass(fontSizeType.className);
|
||||
@@ -90,9 +88,7 @@ export function setAppFontSize(type: number): void {
|
||||
export function getFontSizePreviewClassName(type: number): string {
|
||||
const allFontSizes = FontSize.values();
|
||||
|
||||
for (let i = 0; i < allFontSizes.length; i++) {
|
||||
const fontSizeType = allFontSizes[i];
|
||||
|
||||
for (const fontSizeType of allFontSizes) {
|
||||
if (fontSizeType.type === type) {
|
||||
return FONT_SIZE_PREVIEW_CLASSNAME_PREFIX + fontSizeType.className;
|
||||
}
|
||||
@@ -109,8 +105,7 @@ export function getElementActualHeights(selector: string): Record<string, number
|
||||
return heights;
|
||||
}
|
||||
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
const el = elements[i];
|
||||
for (const el of elements) {
|
||||
const rect = el.getBoundingClientRect();
|
||||
heights[el.id] = rect.height;
|
||||
}
|
||||
|
||||
+3
-3
@@ -180,7 +180,7 @@ export function verifyWebAuthnCredential(userInfo: UserBasicInfo, credentialId:
|
||||
}) as PublicKeyCredentialRequestOptions;
|
||||
|
||||
if (publicKeyCredentialRequestOptions.allowCredentials && publicKeyCredentialRequestOptions.allowCredentials.length > 0) {
|
||||
publicKeyCredentialRequestOptions.allowCredentials[0].id = stringToArrayBuffer(base64decode(credentialId));
|
||||
publicKeyCredentialRequestOptions.allowCredentials[0]!.id = stringToArrayBuffer(base64decode(credentialId));
|
||||
}
|
||||
|
||||
logger.debug('webauthn get options', publicKeyCredentialRequestOptions);
|
||||
@@ -199,8 +199,8 @@ export function verifyWebAuthnCredential(userInfo: UserBasicInfo, credentialId:
|
||||
userIdParts && userIdParts.length === 2 && userIdParts[0] === userInfo.username) {
|
||||
const ret: WebAuthnVerifyResponse = {
|
||||
id: base64encode(rawCredential.rawId),
|
||||
userName: userIdParts[0],
|
||||
userSecret: userIdParts[1],
|
||||
userName: userIdParts[0] as string,
|
||||
userSecret: userIdParts[1] as string,
|
||||
clientData: clientData,
|
||||
rawCredential: rawCredential
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user