mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-06 04:29:55 +02:00
Resolve #630: "Do not allow tab closure during upload"
This commit is contained in:
parent
1486d6301e
commit
77b41fc0b4
3 changed files with 28 additions and 1 deletions
|
@ -169,14 +169,24 @@ export default {
|
|||
id: "fileUpload",
|
||||
handler: this.handleImportEvent
|
||||
});
|
||||
window.onbeforeunload = e => this.onBeforeUnload(e);
|
||||
},
|
||||
destroyed() {
|
||||
this.$store.commit("ui/removeWebsocketEventHandler", {
|
||||
eventName: "import.status_updated",
|
||||
id: "fileUpload"
|
||||
});
|
||||
window.onbeforeunload = null;
|
||||
},
|
||||
methods: {
|
||||
onBeforeUnload(e = {}) {
|
||||
const returnValue = ('This page is asking you to confirm that you want to leave - data you have entered may not be saved.');
|
||||
if (!this.hasActiveUploads) return null;
|
||||
Object.assign(e, {
|
||||
returnValue,
|
||||
});
|
||||
return returnValue;
|
||||
},
|
||||
inputFile(newFile, oldFile) {
|
||||
this.$refs.upload.active = true;
|
||||
},
|
||||
|
@ -294,6 +304,9 @@ export default {
|
|||
f.statusIndex = statusIndex
|
||||
return f
|
||||
}), ['statusIndex', 'name'])
|
||||
},
|
||||
hasActiveUploads () {
|
||||
return this.sortedFiles.filter((f) => { return f.active }).length > 0
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue