Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.

don't show the download button until the filename is loaded #736

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/templates/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ module.exports = function(state, emit) {
</button>
</div>
</div>`;
if (!state.transfer) {
const ele = action.querySelector('#download-btn');
Copy link
Contributor

Choose a reason for hiding this comment

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

This breaks on the server side. The server also runs this code from here, but there action is not a DOMElement it's just a string. So we end up in the catch case which falls through to the notfound code.

A good way to make it work on both the server and browser is to conditionally add the button in the action template string instead of removing it after.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure I will look into this in a while

ele.parentNode.removeChild(ele);
}
if (fileInfo.pwd && !fileInfo.password) {
action = downloadPassword(state, emit);
} else if (!state.transfer) {
Expand Down