mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 09:14:27 +08:00
improve performance
This commit is contained in:
+2
-23
@@ -358,25 +358,13 @@ const stores = {
|
|||||||
item.sourceAccount = state.allAccountsMap[item.sourceAccountId];
|
item.sourceAccount = state.allAccountsMap[item.sourceAccountId];
|
||||||
item.destinationAccount = state.allAccountsMap[item.destinationAccountId];
|
item.destinationAccount = state.allAccountsMap[item.destinationAccountId];
|
||||||
item.category = state.allTransactionCategoriesMap[item.categoryId];
|
item.category = state.allTransactionCategoriesMap[item.categoryId];
|
||||||
item.tags = [];
|
|
||||||
|
|
||||||
if (item.tagIds && item.tagIds.length) {
|
|
||||||
for (let j = 0; j < item.tagIds.length; j++) {
|
|
||||||
const tag = state.allTransactionTagsMap[item.tagIds[j]];
|
|
||||||
|
|
||||||
if (tag) {
|
|
||||||
item.tags.push(tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const transactionYear = utils.getYear(transactionTime);
|
const transactionYear = utils.getYear(transactionTime);
|
||||||
const transactionMonth = utils.getMonth(transactionTime);
|
const transactionMonth = utils.getMonth(transactionTime);
|
||||||
const transactionYearMonth = utils.getYearAndMonth(transactionTime);
|
const transactionYearMonth = utils.getYearAndMonth(transactionTime);
|
||||||
|
|
||||||
if (currentMonthList && currentMonthList.year === transactionYear && currentMonthList.month === transactionMonth) {
|
if (currentMonthList && currentMonthList.year === transactionYear && currentMonthList.month === transactionMonth) {
|
||||||
currentMonthList.items.push(item);
|
currentMonthList.items.push(Object.freeze(item));
|
||||||
calculateMonthTotalAmount(state, currentMonthList, defaultCurrency, accountId, true);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,19 +372,10 @@ const stores = {
|
|||||||
if (state.transactions[j].year === transactionYear && state.transactions[j].month === transactionMonth) {
|
if (state.transactions[j].year === transactionYear && state.transactions[j].month === transactionMonth) {
|
||||||
currentMonthListIndex = j;
|
currentMonthListIndex = j;
|
||||||
currentMonthList = state.transactions[j];
|
currentMonthList = state.transactions[j];
|
||||||
|
|
||||||
if (j > 0) {
|
|
||||||
calculateMonthTotalAmount(state, state.transactions[j - 1], defaultCurrency, accountId, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentMonthList && state.transactions.length > 0) {
|
|
||||||
calculateMonthTotalAmount(state, state.transactions[state.transactions.length - 1], defaultCurrency, accountId, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!currentMonthList || currentMonthList.year !== transactionYear || currentMonthList.month !== transactionMonth) {
|
if (!currentMonthList || currentMonthList.year !== transactionYear || currentMonthList.month !== transactionMonth) {
|
||||||
calculateMonthTotalAmount(state, currentMonthList, defaultCurrency, accountId, false);
|
calculateMonthTotalAmount(state, currentMonthList, defaultCurrency, accountId, false);
|
||||||
|
|
||||||
@@ -412,7 +391,7 @@ const stores = {
|
|||||||
currentMonthList = state.transactions[state.transactions.length - 1];
|
currentMonthList = state.transactions[state.transactions.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
currentMonthList.items.push(item);
|
currentMonthList.items.push(Object.freeze(item));
|
||||||
calculateMonthTotalAmount(state, currentMonthList, defaultCurrency, accountId, true);
|
calculateMonthTotalAmount(state, currentMonthList, defaultCurrency, accountId, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user