Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use patch for list updates #1511

Merged
merged 8 commits into from
Feb 9, 2021
Merged

Use patch for list updates #1511

merged 8 commits into from
Feb 9, 2021

Conversation

jpope19
Copy link
Contributor

@jpope19 jpope19 commented Dec 16, 2020

No description provided.

@@ -22,9 +22,27 @@ export function updateList(store, { listName, fn }) {
store.commit(LIST_LOAD_PENDING, { listName });

return getListFromAPI(prefix, listName)
// TODO check this error and make sure its a 404 before returning an empty array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this, clay swallowing errors has been a pain point x.x

@@ -16,7 +16,7 @@
<script>
import _ from 'lodash';
import item from './autocomplete-item.vue';
import { getProp, removeListItem } from '../lib/lists/helpers';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removeLIstItem and addListItem are no longer used (and shouldn't be used) so they can be removed

@@ -22,9 +22,27 @@ export function updateList(store, { listName, fn }) {
store.commit(LIST_LOAD_PENDING, { listName });

return getListFromAPI(prefix, listName)
// TODO check this error and make sure its a 404 before returning an empty array
.catch(() => []) // allow adding to a new list
.then(listItems => fn(_.cloneDeep(listItems)))
.then(listItems => saveList(prefix, listName, listItems))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it looks like the remaining lists using 'updateList' are new-pages and bookmarks, neither of which will ever reach a large number of items.

However if we keep updateList in the codebase, then

  1. future clay devs may introduce it to update a large list without realizing
  2. plugins may introduce bugs by dispatching an action for a large list.

so I could see value in forcing patchList to be used moving forward (i.e. remove updateList). But no strong opinions there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea i was hesitant to remove it from the codebase in case there were already existing plugins that used it. and because of this, felt like it'd be a waste of time re-writing the bookmarks/new-pages logic.

i'll definitely rework those two functions to use patchList though, if we think it'd be beneficial

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah, the trouble of moving people off updateList when it is likely fine for 99% of lists - is probably not worth it.

so yeah i'm good with leaving this as is

@coveralls
Copy link

coveralls commented Dec 29, 2020

Coverage Status

Coverage decreased (-0.2%) to 34.846% when pulling 4e5af99 on modify-lists into c8d2bce on master.

@jpope19 jpope19 changed the title [WIP] use patch for list updates Use patch for list updates Jan 4, 2021
lib/lists/actions.js Outdated Show resolved Hide resolved
@jpope19 jpope19 merged commit 985077e into master Feb 9, 2021
@jpope19 jpope19 deleted the modify-lists branch February 9, 2021 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants