Allow retrying failed tag sync
This commit is contained in:
		
							parent
							
								
									3b22fe98f2
								
							
						
					
					
						commit
						199a44a8a7
					
				
					 3 changed files with 15 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -29,7 +29,7 @@ if downloader.total > 0 || downloader.outcome
 | 
			
		|||
          .s-progress--bar(style=`width: ${percentage}`)
 | 
			
		||||
        .d-flex.jc-space-between.fs-fine
 | 
			
		||||
          span= percentage
 | 
			
		||||
          span= downloader.total
 | 
			
		||||
          span processed #{downloader.processed} of #{downloader.total}
 | 
			
		||||
 | 
			
		||||
    else if downloader.outcome === "Success"
 | 
			
		||||
      .s-notice.s-notice__success.p8.gx16.pl16.d-flex.ai-center
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +40,9 @@ if downloader.total > 0 || downloader.outcome
 | 
			
		|||
        a.s-btn.s-btn__outlined(href=and({arrange: "tag", shape: "grid"})) Refresh
 | 
			
		||||
 | 
			
		||||
    else
 | 
			
		||||
      .s-notice.s-notice__danger.p8.gx16.pl16.d-flex.ai-center
 | 
			
		||||
      form.s-notice.s-notice__danger.d-flex.ai-center.p8.gx16.pl16(role="status" hx-target="#tag-download" hx-select="#tag-download" hx-post="/api/tag-download")
 | 
			
		||||
        title#title(hx-swap-oob="true") * Tag download failed! | BC Explorer
 | 
			
		||||
        != icons.get("cloud-xmark")
 | 
			
		||||
        .fl-grow1= downloader.outcome
 | 
			
		||||
        input(type="hidden" name="account" value=account)
 | 
			
		||||
        button.s-btn.s-btn__outlined Try again
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -66,13 +66,10 @@ async function loadCollection(inputUsername) {
 | 
			
		|||
				})
 | 
			
		||||
			} catch (cause) {
 | 
			
		||||
				throw new class extends Error {
 | 
			
		||||
					constructor() {
 | 
			
		||||
						super("Unsupported album/track data", {cause})
 | 
			
		||||
						this.name = "Collection Import Error"
 | 
			
		||||
						this.account = account
 | 
			
		||||
						this.item = item
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
					name = "Item Import Error"
 | 
			
		||||
					item = item
 | 
			
		||||
					cause = cause
 | 
			
		||||
				}("Unsupported album/track data")
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	})()
 | 
			
		||||
| 
						 | 
				
			
			@ -112,7 +109,12 @@ router.post("/api/load-collection", defineEventHandler(async event => {
 | 
			
		|||
		const result = await loadCollection(account)
 | 
			
		||||
		setCookie(event, "accounts", (getCookie(event, "accounts") || "").split("|").concat(account).join("|"))
 | 
			
		||||
		return pugSync.render(event, "collection-loaded.pug", result)
 | 
			
		||||
	} catch (error) {
 | 
			
		||||
	} catch (cause) {
 | 
			
		||||
		const error = new class extends Error {
 | 
			
		||||
			name = "Collection Import Error"
 | 
			
		||||
			account = account
 | 
			
		||||
			cause = cause
 | 
			
		||||
		}("Details logged to console. Please ask Cadence to fix it!")
 | 
			
		||||
		console.error(error)
 | 
			
		||||
		return pugSync.render(event, "collection-loaded.pug", {error})
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,7 +88,7 @@ class TagDownloader extends sync.reloadClassMethods(() => TagDownloader) {
 | 
			
		|||
			}
 | 
			
		||||
			this.outcome = "Success"
 | 
			
		||||
		} catch (e) {
 | 
			
		||||
			console.error(`error downloading tags for ${this.account} - ${e}`)
 | 
			
		||||
			console.error(`error downloading tags for ${this.account} -`, e)
 | 
			
		||||
			this.outcome = e.toString()
 | 
			
		||||
		} finally {
 | 
			
		||||
			this.running = false
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue