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

[BUG] Cache does not seem to be working on FileList component #3248

Closed
russgove opened this issue Jul 3, 2024 · 1 comment · Fixed by #3257
Closed

[BUG] Cache does not seem to be working on FileList component #3248

russgove opened this issue Jul 3, 2024 · 1 comment · Fixed by #3257
Assignees
Labels
bug Something isn't working Component: file-list
Milestone

Comments

@russgove
Copy link
Contributor

russgove commented Jul 3, 2024

I am using the filelist component in a teams tab. The component keeps making calls to the graph to get the files even though they were already loaded and are in the cache.

 <FileList
            siteId={props.displayFolder.SiteId}
            driveId={props.displayFolder.DriveId}
            itemId={localFolderId}
            disableOpenOnClick={true}
            pageSize={10}

            key={localFolderId}
            itemClick={itemSelected()}>
            <MyEvent template="loading"></MyEvent>
        </FileList>

To Reproduce
Steps to reproduce the behavior:

  1. Add a filelist component to a teams tab.
  2. Run the app
  3. Start fiddler
  4. reload the page several times
  5. You will see the calls made to the graph to get the files on each reload

Expected behavior
The files should be retrieved from the cache
n your problem.

Environment (please complete the following information):

  • OS: Windows
  • Browser Edge
  • Framework react
  • ContextMicrosoft Teams
  • Version 4.2.3
  • Provider ProxyProvider

Additional context
In troubleshooting this i ended up looking at the GetIterator method in graph.files.ts
When we are getting files from the cache we use this:
const fileList = await getFileListFromCache(cache, storeName, ${endpoint}:${top});

When adding files to the cache we use this

await cache.putValue(endpoint, {
files: filesPageIterator.value.map(v => JSON.stringify(v)),
nextLink
});

so the keys to not seem to match. When we get the key is ${endpoint}:${top}, when we put the key is endpoint.

@russgove russgove added bug Something isn't working Needs: Triage 🔍 labels Jul 3, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Graph Toolkit Jul 3, 2024
@musale
Copy link
Contributor

musale commented Jul 16, 2024

@russgove thank you for figuring this out! I can confirm that the keys are inconsistent in

const fileList = await getFileListFromCache(cache, storeName, `${endpoint}:${top}`);

and in getting the values here:

await cache.putValue(endpoint, {
files: filesPageIterator.value.map(v => JSON.stringify(v)),
nextLink
});

The key can be moved out to its own variable and reused throughout the code block. Would you be interested in putting up a PR for this?

@musale musale added this to the 4.2.4 milestone Jul 16, 2024
@github-project-automation github-project-automation bot moved this from Needs Triage 🔍 to Done ✔️ in Graph Toolkit Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Component: file-list
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants