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

State gets confused after moving, deleting, uploading files. #809

Closed
1 task done
maxime-rainville opened this issue Jul 16, 2018 · 2 comments
Closed
1 task done

Comments

@maxime-rainville
Copy link
Contributor

maxime-rainville commented Jul 16, 2018

Asset-admin has an annoying tendency to mix up its state when doing file operation. Which leads to ghost file entries.

Here's a couple examples:

PR's

@bergice
Copy link
Contributor

bergice commented Sep 25, 2018

Seems like this could be a race condition.

Replacing this.props.actions.files.readFiles(); with setInterval(this.props.actions.files.readFiles, 10); at vendor/silverstripe/asset-admin/client/src/containers/AssetAdmin/AssetAdmin.js:645 seems to resolve the file not updating its location when moved between folders.

Could be that the mutation is not completed before the state is refetched, but that would be strange as this is invoked in the success handler.

[Edit]

Maybe this is related? apollographql/apollo-client#1821

@bergice
Copy link
Contributor

bergice commented Sep 30, 2018

The problem is that we are not updating the cache manually after the move file/delete file mutations. We need to ensure the cache is always up to date.

This becomes tricky with the move file mutation as we can easily write the updated query to GraphQL, but with the pagination, sorting and search filters we would need to write every combination of these variables to the updated query. This is not a viable option and it does not look like Apollo GraphQL has a way for us to clear the cache for a specific query regardless of the variables provided.

Discussions around caching invalidation:

The closest option would be to clear the store itself or just prevent the readFilesQuery from using the cache by setting the options.fetchPolicy to network-only.

bergice added a commit to open-sausages/silverstripe-asset-admin that referenced this issue Oct 1, 2018
…iles

Apollo GraphQL does not currently have a way to invalidate cache without clearing the whole store

Fixes silverstripe#809
@bergice bergice removed their assignment Oct 1, 2018
bergice added a commit to open-sausages/silverstripe-asset-admin that referenced this issue Oct 1, 2018
…iles

Apollo GraphQL does not currently have a way to invalidate cache without clearing the whole store

Fixes silverstripe#809
bergice added a commit to open-sausages/silverstripe-asset-admin that referenced this issue Oct 2, 2018
…iles

Apollo GraphQL does not currently have a way to invalidate cache without clearing the whole store

Fixes silverstripe#809
bergice added a commit to open-sausages/silverstripe-asset-admin that referenced this issue Oct 2, 2018
…iles

Apollo GraphQL does not currently have a way to invalidate cache without clearing the whole store

Fixes silverstripe#809
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants