With both the subfolder and parent folder caching, we won't necessarily be writing new code, but reorganizing and repurposing the existing code into a more modular system, so that each part can be called separately.
The following flowchart should help you visualize the steps required to cache the current folder and subfolders:
When looking at the flowchart, you can immediately see some duplication in events required for the app. At two points the app needs to decide whether a folder exists in the cache and, if it does not, query the API to get the data and store the result. Although it appears only twice on the flowchart, this functionality is required several times, once for every folder in the current location.
We will also need to separate out our displaying logic from our querying and storing logic, as we may need to load from the API and store, without...