-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Support previews of non-current file versions (#608)
This patch adds support for previewing non-current file versions. Specify the file version like so: ``` const preview = new Box.Preview(); preview.show(FILE_ID_1, ACCESS_TOKEN, { fileOptions: { [FILE_ID_1]: { fileVersionId: FILE_VERSION_ID_1 } } }); ``` In this patch, we start caching file objects by both file ID and by file version ID, distinguishing between the two with a 'file_' or 'file_version_' prefix as the key to the cache. This allows us to be backwards-compatible and show the current file version if no file version ID is passed in, while always allowing a cached entry of a current version to be overriden when you preview a non-current file version. We abstract this logic to file.js, and rely on the helper methods cacheFile(), uncacheFile(), and getCachedFile() to interact with file objects and the cache. This patch also enables prefetching of files that were previously cached by file ID or file version ID. To support previews of file versions, we introduce a new Preview option `fileOptions`, which allows us to specific individual options by file ID. This is needed instead of just passing in a `fileVersionId` opion since we support collections. Having this mapping of file ID to file options on that file ID allows us to specify file verison IDs for any number of file IDs to preview and can also be extended to support other file-level options in the future. Example of collection + file version support together: ``` const preview = new Box.Preview(); preview.show(FILE_ID_1, ACCESS_TOKEN, { collection: [FILE_ID_1, FILE_ID2], fileOptions: { [FILE_ID_1]: { fileVersionId: FILE_VERSION_ID_1 }, [FILE_ID_2]: { fileVersionId: FILE_VERSION_ID_2 } } }); ``` Caveats: - You cannot pass in the current file version ID as an option since the Box API will fail when you make a get file version info API call for the current version - Preview events do not distinguish between file versions, so a preview of a previous file version will be simply logged as a preview of a file ID This resolves #570.
- Loading branch information
Showing
7 changed files
with
411 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.