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

Chore: Preview.js cleanup and slight refactor #24

Merged
merged 1 commit into from
Mar 28, 2017
Merged

Chore: Preview.js cleanup and slight refactor #24

merged 1 commit into from
Mar 28, 2017

Conversation

tonyjin
Copy link
Contributor

@tonyjin tonyjin commented Mar 28, 2017

  • Update show() to only take file IDs since we are not planning on accepting file objects
  • Cleaned up some logic and comments concerning cached file metadata

@@ -621,12 +608,9 @@ class Preview extends EventEmitter {
// Update navigation
showNavigation(this.file.id, this.collection);

// Cache the file
cacheFile(this.file);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@priyajeet not sure why we had this extra caching here - we already cache when needed after loading from the server in handleLoadResponse(). We shouldn't have to cache anything here right?

Copy link
Contributor

@priyajeet priyajeet Mar 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could have been there to prevent prefetch() from trying to prefetch something that was loading...Dunno if its still needed after all the prefetch refactoring.

@tonyjin
Copy link
Contributor Author

tonyjin commented Mar 28, 2017

For a bit of context, I started down this path while investigating a very intermittent bug where a preview can get stuck in the 'Generating Preview...' state without the loading download button link ever showing up (my one tab has been in this state for 5 hours now).

2017-03-27_23-40-07

In the stuck state, the static assets for the document viewer are not loaded - this implies we have not yet picked an appropriate viewer for the file and that we also haven't yet reached showLoadingDownloadButton() in loadViewer(). Looking above in handleLoadResponse() (this situation happened for a fresh Preview that was not cached), I suspect there is some situation where this.loadViewer() was not being called due to some caching logic error.

@@ -770,19 +754,26 @@ class Preview extends EventEmitter {
// Keep reference to previously cached file version
const cached = cache.get(file.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prolly rename to cachedFile ^

const isWatermarked = file.watermark_info && file.watermark_info.is_watermarked;
const isStale = !cached || !cached.file_version || cached.file_version.sha1 !== file.file_version.sha1;

// Don't cache watermarked files, update cache otherwise
if (isWatermarked) {
cache.unset(file.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to uncacheFile

cached.file_version.sha1 !== file.file_version.sha1 ||
isWatermarked;

if (shouldLoadViewer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldReloadViewer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily reload - this is also the flow for a viewer to be loaded the first time

- Update show() to only take file IDs since we are not planning on accepting file objects
- Cleaned up some logic and comments concerning cached file metadata
@tonyjin tonyjin merged commit eca2ae4 into box:master Mar 28, 2017
@tonyjin tonyjin deleted the refactor-preview branch March 28, 2017 20:06
tonyjin pushed a commit to tonyjin/box-content-preview that referenced this pull request Aug 22, 2017
- Partially reverts changes from box#24.
- Adds 'id' to FILE_FIELDS since we use that to validate the file object passed in
tonyjin added a commit that referenced this pull request Aug 22, 2017
- Partially reverts changes from #24.
- Adds 'id' to FILE_FIELDS since we use that to validate the file object passed in
pramodsum added a commit to pramodsum/box-content-preview that referenced this pull request Nov 14, 2017
https://github.com/box/box-annotations/releases

# 0.3.0 (2017-11-14)
* Chore: Add conventional-changelog-releaser (box#34) ([624e0bd](box/box-annotations@624e0bd))
* Chore: Do not clear out node_modules on when publishing npm package (box#30) ([08c180d](box/box-annotations@08c180d))
* Fix: Do not select drawings when creating a point annotation on top (box#28) ([07fc4c1](box/box-annotations@07fc4c1))
* Fix: Drawing CSS (box#23) ([0493fcd](box/box-annotations@0493fcd))
* Fix: fix highlight selection and typos (box#21) ([ca54d5e](box/box-annotations@ca54d5e)), closes [box#21](box/box-annotations#21)
* Fix: Hide createHighlightDialog on page re-render (box#31) ([0b74717](box/box-annotations@0b74717))
* Fix: Match width of reply textarea with comments (box#33) ([5f0f29b](box/box-annotations@5f0f29b))
* Fix: Only registering thread with controller on save (box#22) ([ff75bf1](box/box-annotations@ff75bf1))
* Fix: Only show create dialog when creating new point annotations (box#29) ([4822ece](box/box-annotations@4822ece))
* Fix: only show newly created annotation dialog on hover (box#25) ([0ba1965](box/box-annotations@0ba1965))
* Fix: Position create dialog properly near page edges (box#32) ([968efb3](box/box-annotations@968efb3))
* Fix: release script should use correct remote branch (box#20) ([8bd12a5](box/box-annotations@8bd12a5))
* Fix: Scrolling on highlight dialogs in powerpoints (box#24) ([b21ed0e](box/box-annotations@b21ed0e))
* Fix: Validation message fails to get displayed when user clicks on 'Post' without entering any comme ([d90e72c](box/box-annotations@d90e72c))
*  Fix: Hide mobile dialog on first outside click (box#26) ([01ec48b](box/box-annotations@01ec48b))
pramodsum added a commit that referenced this pull request Nov 14, 2017
https://github.com/box/box-annotations/releases

# 0.3.0 (2017-11-14)
* Chore: Add conventional-changelog-releaser (#34) ([624e0bd](box/box-annotations@624e0bd))
* Chore: Do not clear out node_modules on when publishing npm package (#30) ([08c180d](box/box-annotations@08c180d))
* Fix: Do not select drawings when creating a point annotation on top (#28) ([07fc4c1](box/box-annotations@07fc4c1))
* Fix: Drawing CSS (#23) ([0493fcd](box/box-annotations@0493fcd))
* Fix: fix highlight selection and typos (#21) ([ca54d5e](box/box-annotations@ca54d5e)), closes [#21](box/box-annotations#21)
* Fix: Hide createHighlightDialog on page re-render (#31) ([0b74717](box/box-annotations@0b74717))
* Fix: Match width of reply textarea with comments (#33) ([5f0f29b](box/box-annotations@5f0f29b))
* Fix: Only registering thread with controller on save (#22) ([ff75bf1](box/box-annotations@ff75bf1))
* Fix: Only show create dialog when creating new point annotations (#29) ([4822ece](box/box-annotations@4822ece))
* Fix: only show newly created annotation dialog on hover (#25) ([0ba1965](box/box-annotations@0ba1965))
* Fix: Position create dialog properly near page edges (#32) ([968efb3](box/box-annotations@968efb3))
* Fix: release script should use correct remote branch (#20) ([8bd12a5](box/box-annotations@8bd12a5))
* Fix: Scrolling on highlight dialogs in powerpoints (#24) ([b21ed0e](box/box-annotations@b21ed0e))
* Fix: Validation message fails to get displayed when user clicks on 'Post' without entering any comme ([d90e72c](box/box-annotations@d90e72c))
*  Fix: Hide mobile dialog on first outside click (#26) ([01ec48b](box/box-annotations@01ec48b))
pramodsum added a commit to pramodsum/box-content-preview that referenced this pull request Nov 16, 2017
https://github.com/box/box-annotations/releases

# 0.3.0 (2017-11-14)
* Chore: Add conventional-changelog-releaser (box#34) ([624e0bd](box/box-annotations@624e0bd))
* Chore: Do not clear out node_modules on when publishing npm package (box#30) ([08c180d](box/box-annotations@08c180d))
* Fix: Do not select drawings when creating a point annotation on top (box#28) ([07fc4c1](box/box-annotations@07fc4c1))
* Fix: Drawing CSS (box#23) ([0493fcd](box/box-annotations@0493fcd))
* Fix: fix highlight selection and typos (box#21) ([ca54d5e](box/box-annotations@ca54d5e)), closes [box#21](box/box-annotations#21)
* Fix: Hide createHighlightDialog on page re-render (box#31) ([0b74717](box/box-annotations@0b74717))
* Fix: Match width of reply textarea with comments (box#33) ([5f0f29b](box/box-annotations@5f0f29b))
* Fix: Only registering thread with controller on save (box#22) ([ff75bf1](box/box-annotations@ff75bf1))
* Fix: Only show create dialog when creating new point annotations (box#29) ([4822ece](box/box-annotations@4822ece))
* Fix: only show newly created annotation dialog on hover (box#25) ([0ba1965](box/box-annotations@0ba1965))
* Fix: Position create dialog properly near page edges (box#32) ([968efb3](box/box-annotations@968efb3))
* Fix: release script should use correct remote branch (box#20) ([8bd12a5](box/box-annotations@8bd12a5))
* Fix: Scrolling on highlight dialogs in powerpoints (box#24) ([b21ed0e](box/box-annotations@b21ed0e))
* Fix: Validation message fails to get displayed when user clicks on 'Post' without entering any comme ([d90e72c](box/box-annotations@d90e72c))
*  Fix: Hide mobile dialog on first outside click (box#26) ([01ec48b](box/box-annotations@01ec48b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants