A local-first personal finance app
Do not request transactions when listing accounts (#482)
Robert Dyerc9e6d7897b09
diff --git a/src/app-simplefin/app-simplefin.js b/src/app-simplefin/app-simplefin.jsindex 7951526e3f..a1729b1ce8 100644--- a/src/app-simplefin/app-simplefin.js+++ b/src/app-simplefin/app-simplefin.js@@ -47,12 +47,8 @@ app.post(return;}- const now = new Date();- const startDate = new Date(now.getFullYear(), now.getMonth(), 1);- const endDate = new Date(now.getFullYear(), now.getMonth() + 1, 1);-try {- const accounts = await getAccounts(accessKey, startDate, endDate);+ const accounts = await getAccounts(accessKey, null, null, true);res.send({status: 'ok',@@ -313,7 +309,12 @@ function normalizeDate(date) {return (date.valueOf() - date.getTimezoneOffset() * 60 * 1000) / 1000;}-async function getAccounts(accessKey, startDate, endDate) {+async function getAccounts(+ accessKey,+ startDate,+ endDate,+ noTransactions = false,+) {const sfin = parseAccessKey(accessKey);const options = {headers: {@@ -323,16 +324,20 @@ async function getAccounts(accessKey, startDate, endDate) {},};const params = [];- let queryString = '';- if (startDate) {- params.push(`start-date=${normalizeDate(startDate)}`);- }- if (endDate) {- params.push(`end-date=${normalizeDate(endDate)}`);- }+ if (!noTransactions) {+ if (startDate) {+ params.push(`start-date=${normalizeDate(startDate)}`);+ }+ if (endDate) {+ params.push(`end-date=${normalizeDate(endDate)}`);+ }- params.push(`pending=1`);+ params.push(`pending=1`);+ } else {+ params.push(`balances-only=1`);+ }+ let queryString = '';if (params.length > 0) {queryString += '?' + params.join('&');}diff --git a/upcoming-release-notes/482.md b/upcoming-release-notes/482.mdnew file mode 100644index 0000000000..80004c4756--- /dev/null+++ b/upcoming-release-notes/482.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [psybers]+---++Don't pull transactions from SimpleFIN when asking for the list of accounts.