From 399b6a9c823eb0fc964efb683c921a56e01fe6f5 Mon Sep 17 00:00:00 2001
From: RemixDev <RemixDev64@gmail.com>
Date: Fri, 19 Aug 2022 23:43:22 +0200
Subject: [PATCH] Added retry function for failed downloads

---
 src/components/downloads/QueueItem.vue      | 2 +-
 src/components/downloads/TheDownloadBar.vue | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/components/downloads/QueueItem.vue b/src/components/downloads/QueueItem.vue
index 397aa42..fbe67a5 100644
--- a/src/components/downloads/QueueItem.vue
+++ b/src/components/downloads/QueueItem.vue
@@ -173,7 +173,7 @@ export default {
 		onResultIconClick() {
 			if (this.isDeterminateStatus) {
 				if (this.finishedWithFails) {
-					this.$emit('show-errors', this.queueItem)
+					this.$emit('retry-download', this.queueItem.uuid)
 				}
 
 				if (this.queueItem.status === 'downloading') {
diff --git a/src/components/downloads/TheDownloadBar.vue b/src/components/downloads/TheDownloadBar.vue
index cceadd9..3fe8ff3 100644
--- a/src/components/downloads/TheDownloadBar.vue
+++ b/src/components/downloads/TheDownloadBar.vue
@@ -59,6 +59,7 @@
 				:show-tags="showTags"
 				@show-errors="showErrorsTab"
 				@remove-item="onRemoveItem"
+				@retry-download="onRetryDownload"
 			/>
 		</div>
 	</section>
@@ -70,7 +71,7 @@ import QueueItem from '@components/downloads/QueueItem.vue'
 
 import { socket } from '@/utils/socket'
 import { toast } from '@/utils/toasts'
-import { fetchData } from '@/utils/api'
+import { fetchData, postToServer } from '@/utils/api'
 
 const tabMinWidth = 250
 const tabMaxWidth = 500
@@ -153,6 +154,10 @@ export default {
 		onRemoveItem(uuid) {
 			socket.emit('removeFromQueue', uuid)
 		},
+		onRetryDownload(uuid) {
+			console.log("Retry", uuid)
+			postToServer('retryDownload', {uuid})
+		},
 		setTabWidth(newWidth) {
 			if (undefined === newWidth) {
 				this.$refs.container.style.width = ''