Change directory tree to use Metadata update event
Metadata model provides an "update" event which is triggered anytime a metadata item has been updated from the backend. Any UI part that to display latest metadata should listen to it and update the UI accordingly. Change the directory tree to listen to Metadata "update" event to update the "shared" icon. A listener is added for every expanded folder to listen to updates for its sub-folders. When a folder is collapsed its listener is removed. Change |onExpand_| function to fetch all metadata values from |LIST_CONTAINER_METADATA_PREFETCH_PROPERTY_NAMES|, instead of |DIRECTORY_TREE_METADATA_PREFETCH_PROPERTY_NAMES|. Directory tree needs the metadata "can*" to setup permission accordingly in the context menu. This is only fetched for Drive roots, since only Drive implements these metadata. Change |updateSharedStatusIcon| function to use the cached metadata value. This fixes the issue where it would trigger metadata requests to backend too early, because this |updateSharedStatusIcon| is called from SubDirectoryItem constructor. Remove Metadata cache invalidation calls (notifyEntriesChanged and notifyEntriesRemoved) because directory tree doesn't update metadata directly. Fix MockVolumeManager to work with other volumes other than Drive, by extracting the VolumeManager implementation to detect RootType to a common function |getRootTypeFromVolumeType|. Remove constant |DIRECTORY_TREE_METADATA_PREFETCH_PROPERTY_NAMES| since its use has been removed in directory_tree.js. Add MetadataModel |removeEventListener| to be able to remove listener of MetadataModel "update" event. manual tests for Drive "shared" icon. New integration tests for "shared" icon will be added in follow up CL. Bug: 880187, 880189 Test: Unittest for |insideMyDrive| and |insideDrive| functions and Change-Id: Ibe8320e7b0981d8e9556ebb8a922d7db2f16860c Reviewed-on: https://chromium-review.googlesource.com/1203596 Commit-Queue: Luciano Pacheco <lucmult@chromium.org> Reviewed-by:Noel Gordon <noel@chromium.org> Cr-Commit-Position: refs/heads/master@{#589846}
Showing
Please register or sign in to comment