mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 09:14:27 +08:00
remove unnecessary mutation committing
This commit is contained in:
+11
-3
@@ -31,7 +31,10 @@ export function loadAllAccounts(context, { force }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.commit(LOAD_ACCOUNT_LIST, data.result);
|
context.commit(LOAD_ACCOUNT_LIST, data.result);
|
||||||
context.commit(UPDATE_ACCOUNT_LIST_INVALID_STATE, false);
|
|
||||||
|
if (context.state.accountListStateInvalid) {
|
||||||
|
context.commit(UPDATE_ACCOUNT_LIST_INVALID_STATE, false);
|
||||||
|
}
|
||||||
|
|
||||||
resolve(data.result);
|
resolve(data.result);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@@ -138,7 +141,10 @@ export function changeAccountDisplayOrder(context, { accountId, from, to }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.commit(UPDATE_ACCOUNT_LIST_INVALID_STATE, true);
|
if (!context.state.accountListStateInvalid) {
|
||||||
|
context.commit(UPDATE_ACCOUNT_LIST_INVALID_STATE, true);
|
||||||
|
}
|
||||||
|
|
||||||
context.commit(CHANGE_ACCOUNT_DISPLAY_ORDER_IN_ACCOUNT_LIST, {
|
context.commit(CHANGE_ACCOUNT_DISPLAY_ORDER_IN_ACCOUNT_LIST, {
|
||||||
account: account,
|
account: account,
|
||||||
from: from,
|
from: from,
|
||||||
@@ -178,7 +184,9 @@ export function updateAccountDisplayOrders(context) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.commit(UPDATE_ACCOUNT_LIST_INVALID_STATE, false);
|
if (context.state.accountListStateInvalid) {
|
||||||
|
context.commit(UPDATE_ACCOUNT_LIST_INVALID_STATE, false);
|
||||||
|
}
|
||||||
|
|
||||||
resolve(data.result);
|
resolve(data.result);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|||||||
@@ -57,7 +57,10 @@ export function getTransactions(context, { reload, autoExpand, defaultCurrency }
|
|||||||
autoExpand: autoExpand,
|
autoExpand: autoExpand,
|
||||||
defaultCurrency: defaultCurrency
|
defaultCurrency: defaultCurrency
|
||||||
});
|
});
|
||||||
context.commit(UPDATE_TRANSACTION_LIST_INVALID_STATE, true);
|
|
||||||
|
if (!context.state.transactionListStateInvalid) {
|
||||||
|
context.commit(UPDATE_TRANSACTION_LIST_INVALID_STATE, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reject({ message: 'Unable to get transaction list' });
|
reject({ message: 'Unable to get transaction list' });
|
||||||
@@ -72,7 +75,9 @@ export function getTransactions(context, { reload, autoExpand, defaultCurrency }
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (reload) {
|
if (reload) {
|
||||||
context.commit(UPDATE_TRANSACTION_LIST_INVALID_STATE, false);
|
if (context.state.transactionListStateInvalid) {
|
||||||
|
context.commit(UPDATE_TRANSACTION_LIST_INVALID_STATE, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(data.result);
|
resolve(data.result);
|
||||||
@@ -86,7 +91,10 @@ export function getTransactions(context, { reload, autoExpand, defaultCurrency }
|
|||||||
autoExpand: autoExpand,
|
autoExpand: autoExpand,
|
||||||
defaultCurrency: defaultCurrency
|
defaultCurrency: defaultCurrency
|
||||||
});
|
});
|
||||||
context.commit(UPDATE_TRANSACTION_LIST_INVALID_STATE, true);
|
|
||||||
|
if (!context.state.transactionListStateInvalid) {
|
||||||
|
context.commit(UPDATE_TRANSACTION_LIST_INVALID_STATE, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error.response && error.response.data && error.response.data.errorMessage) {
|
if (error.response && error.response.data && error.response.data.errorMessage) {
|
||||||
@@ -150,7 +158,9 @@ export function saveTransaction(context, { transaction, defaultCurrency }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!transaction.id) {
|
if (!transaction.id) {
|
||||||
context.commit(UPDATE_TRANSACTION_LIST_INVALID_STATE, true);
|
if (!context.state.transactionListStateInvalid) {
|
||||||
|
context.commit(UPDATE_TRANSACTION_LIST_INVALID_STATE, true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
context.commit(SAVE_TRANSACTION_IN_TRANSACTION_LIST, {
|
context.commit(SAVE_TRANSACTION_IN_TRANSACTION_LIST, {
|
||||||
transaction: data.result,
|
transaction: data.result,
|
||||||
|
|||||||
@@ -57,7 +57,10 @@ export function loadAllCategories(context, { force }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.commit(LOAD_TRANSACTION_CATEGORY_LIST, data.result);
|
context.commit(LOAD_TRANSACTION_CATEGORY_LIST, data.result);
|
||||||
context.commit(UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE, false);
|
|
||||||
|
if (context.state.transactionCategoryListStateInvalid) {
|
||||||
|
context.commit(UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE, false);
|
||||||
|
}
|
||||||
|
|
||||||
resolve(data.result);
|
resolve(data.result);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@@ -168,7 +171,9 @@ export function addCategories(context, { categories }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.commit(UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE, true);
|
if (!context.state.transactionCategoryListStateInvalid) {
|
||||||
|
context.commit(UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE, true);
|
||||||
|
}
|
||||||
|
|
||||||
resolve(data.result);
|
resolve(data.result);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@@ -208,7 +213,10 @@ export function changeCategoryDisplayOrder(context, { categoryId, from, to }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.commit(UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE, true);
|
if (!context.state.transactionCategoryListStateInvalid) {
|
||||||
|
context.commit(UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE, true);
|
||||||
|
}
|
||||||
|
|
||||||
context.commit(CHANGE_CATEGORY_DISPLAY_ORDER_IN_CATEGORY_LIST, {
|
context.commit(CHANGE_CATEGORY_DISPLAY_ORDER_IN_CATEGORY_LIST, {
|
||||||
category: category,
|
category: category,
|
||||||
from: from,
|
from: from,
|
||||||
@@ -250,7 +258,9 @@ export function updateCategoryDisplayOrders(context, { type, parentId }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.commit(UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE, false);
|
if (context.state.transactionCategoryListStateInvalid) {
|
||||||
|
context.commit(UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE, false);
|
||||||
|
}
|
||||||
|
|
||||||
resolve(data.result);
|
resolve(data.result);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ export function loadAllTags(context, { force }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.commit(LOAD_TRANSACTION_TAG_LIST, data.result);
|
context.commit(LOAD_TRANSACTION_TAG_LIST, data.result);
|
||||||
context.commit(UPDATE_TRANSACTION_TAG_LIST_INVALID_STATE, false);
|
|
||||||
|
if (context.state.transactionTagListStateInvalid) {
|
||||||
|
context.commit(UPDATE_TRANSACTION_TAG_LIST_INVALID_STATE, false);
|
||||||
|
}
|
||||||
|
|
||||||
resolve(data.result);
|
resolve(data.result);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@@ -112,7 +115,10 @@ export function changeTagDisplayOrder(context, { tagId, from, to }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.commit(UPDATE_TRANSACTION_TAG_LIST_INVALID_STATE, true);
|
if (!context.state.transactionTagListStateInvalid) {
|
||||||
|
context.commit(UPDATE_TRANSACTION_TAG_LIST_INVALID_STATE, true);
|
||||||
|
}
|
||||||
|
|
||||||
context.commit(CHANGE_TAG_DISPLAY_ORDER_IN_TRANSACTION_TAG_LIST, {
|
context.commit(CHANGE_TAG_DISPLAY_ORDER_IN_TRANSACTION_TAG_LIST, {
|
||||||
tag: tag,
|
tag: tag,
|
||||||
from: from,
|
from: from,
|
||||||
@@ -144,7 +150,9 @@ export function updateTagDisplayOrders(context) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.commit(UPDATE_TRANSACTION_TAG_LIST_INVALID_STATE, false);
|
if (context.state.transactionTagListStateInvalid) {
|
||||||
|
context.commit(UPDATE_TRANSACTION_TAG_LIST_INVALID_STATE, false);
|
||||||
|
}
|
||||||
|
|
||||||
resolve(data.result);
|
resolve(data.result);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|||||||
Reference in New Issue
Block a user