Skip to content

Commit

Permalink
Improve download feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasvanmol committed Nov 29, 2023
1 parent 0218237 commit f5072b8
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,20 @@ class LatexOCRSettingsTab extends PluginSettingTab {
}));


const checkStatus = () => {
this.plugin.checkLatexOCRServer(500).then(() => {
new Notice("✅ The server is reachable!")
}).catch((err) => {
if (err.includes("downloading")) {
new Notice(`🌐 ${err}`)
} else if (err.includes("loading")) {
new Notice(`⚙️ ${err}`)
} else {
new Notice(`❌ ${err}`)
}
})
}

new Setting(containerEl)
.setName('Server status')
.setDesc("LatexOCR runs a python script in the background that can process OCR requests. \
Expand All @@ -474,20 +488,18 @@ class LatexOCRSettingsTab extends PluginSettingTab {
.addButton(button => button
.setButtonText("Check status")
.onClick(evt => {
this.plugin.checkLatexOCRServer(500).then(() => {
new Notice("✅ The server is reachable!")
}).catch((err) => {
new Notice(`❌ ${err}`)
})
checkStatus()
})
)
.addButton(button => button
.setButtonText("(Re)start server")
.onClick(evt => {
.onClick(async (evt) => {
if (this.plugin.serverProcess) {
this.plugin.serverProcess.kill()
}
this.plugin.startServer()
new Notice("⚙️ Starting server...", 2000)
await this.plugin.startServer()
setTimeout(checkStatus, 2100)
}))


Expand Down

0 comments on commit f5072b8

Please sign in to comment.