Commit list accounts state after difference in removed accounts is determined #82

Merged
floatingghost merged 2 commits from :commit-list-accounts-after-delete into develop 2022-08-01 10:11:40 +00:00
First-time contributor

Currently updated account list in editing a timeline list is being committed to the state before account difference is calculated and acted upon in API DELETE call, which results in no difference between comitted and new lists and accounts being impossible to delete from the list as consequence. Also POST call is executed always with full list of accounts, which is not necessary and both calls are performed regardless of presence of changes. This PR moves calucaltion of difference before the commit, and makes POST/DELETE API calls predicated on non-empty difference.

Currently updated account list in editing a timeline list is being committed to the state before account difference is calculated and acted upon in API DELETE call, which results in no difference between comitted and new lists and accounts being impossible to delete from the list as consequence. Also POST call is executed always with full list of accounts, which is not necessary and both calls are performed regardless of presence of changes. This PR moves calucaltion of difference before the commit, and makes POST/DELETE API calls predicated on non-empty difference.
Ghost added 1 commit 2022-07-30 22:11:36 +00:00
Author
First-time contributor

Added guards for both POST and DELETE API calls so those will only be executed if there was actually some accounts added or removed. Also had to make sure that store getter would return a copy of internal list, so it won't get modified outside the store, otherwise added would always be empty.

Added guards for both POST and DELETE API calls so those will only be executed if there was actually some accounts added or removed. Also had to make sure that store getter would return a copy of internal list, so it won't get modified outside the store, otherwise `added` would always be empty.
floatingghost reviewed 2022-07-31 21:46:43 +00:00
floatingghost left a comment
Owner

one nitpick

seriously though pls do change that bio i don't wanna actually act on any warnings - just... y'know don't make me say it again

one nitpick seriously though pls _do_ change that bio i don't wanna actually act on any warnings - just... y'know don't make me say it again
@ -77,3 +81,3 @@
},
findListAccounts: state => id => {
return state.allListsObject[id].accountIds
return state.allListsObject[id].accountIds.slice()

the preferred way to duplicate an array is via the ... syntax

return [...state.allListsObject[id].accountIds]

the preferred way to duplicate an array is via the `...` syntax `return [...state.allListsObject[id].accountIds]`
Author
First-time contributor

As far as performance goes, ths is less optimal option. But if you want to prioritize readability, sure.

As far as performance goes, ths is less optimal option. But if you want to prioritize readability, sure.

the difference in performance would only actually be relevent if we were dealing with (tens of) thousands of elements, which we're not

the difference in performance would only actually be relevent if we were dealing with (tens of) thousands of elements, which we're not
Ghost marked this conversation as resolved
Ghost force-pushed commit-list-accounts-after-delete from 0d1daa948d to febf0d0c77 2022-08-01 10:07:44 +00:00 Compare
floatingghost merged commit f474763151 into develop 2022-08-01 10:11:40 +00:00
Author
First-time contributor

one nitpick

seriously though pls do change that bio i don't wanna actually act on any warnings - just... y'know don't make me say it again

Sure thing. Done.

> one nitpick > > seriously though pls _do_ change that bio i don't wanna actually act on any warnings - just... y'know don't make me say it again Sure thing. Done.
Sign in to join this conversation.
No description provided.