Skip to content
This repository was archived by the owner on Mar 26, 2024. It is now read-only.

Commit 6c85a28

Browse files
committed
Refactoring, Cleanup: remove all unnecessary debug code, replace vars with vals
1 parent 2e04644 commit 6c85a28

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

projector-launcher/src/main/kotlin/ElectronApp.kt

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,14 @@ import kotlinx.coroutines.await
3030
import kotlinx.coroutines.launch
3131
import org.w3c.dom.url.URL
3232

33-
external fun encodeURI(data: String): String
34-
3533
@OptIn(DelicateCoroutinesApi::class)
3634
class ElectronApp(val url: String) {
3735
var that = this
3836
var configData = js("{}")
3937
var toolboxInfoWasActivated: Boolean = false
4038

4139
var path = require("path")
42-
var node_url = require("url")
40+
//var node_url = require("url") //uncomment to enable "url" module
4341
var node_fs = require("fs")
4442

4543
var app: App = Electron.app
@@ -135,7 +133,7 @@ class ElectronApp(val url: String) {
135133
didFailLoadListener = { _: Event, errorCode: Number, errorDescription: String, validatedURL: String, _: Boolean, _: Number, _: Number ->
136134
GlobalScope.launch(block = {
137135
if (!that.initialized) {
138-
if (!validatedURL.isNullOrBlank()) {
136+
if (!validatedURL.isBlank()) {
139137
messageInvalidURL(validatedURL)
140138
}
141139

@@ -182,16 +180,8 @@ class ElectronApp(val url: String) {
182180
})
183181
}
184182

185-
fun loadMessage(message: String) {
186-
GlobalScope.launch(block = {
187-
that.mainWindow.loadURL("about:blank").await()
188-
var html = "<body><h1>Invalid URL</h1><p>$message</p></body>"
189-
that.mainWindow.loadURL("data:text/html;charset=utf-8," + encodeURI(html)).await()
190-
})
191-
}
192-
193183
fun testUrl(url: String): Boolean {
194-
var result: Boolean = true
184+
var result = true
195185
try {
196186
URL(url)
197187
}
@@ -222,7 +212,7 @@ class ElectronApp(val url: String) {
222212
ipcMain.on("projector-dom-ready") { event, _ ->
223213
ElectronUtil.disableAllStandardShortcuts()
224214

225-
var defaultUrl = this.configData.defaultUrl
215+
val defaultUrl = this.configData.defaultUrl
226216
if (null != defaultUrl) {
227217
event.sender.send("projector-set-url", defaultUrl)
228218
}
@@ -314,7 +304,7 @@ class ElectronApp(val url: String) {
314304
}
315305

316306
fun savedb() {
317-
var data = JSON.stringify(this.configData)
307+
val data = JSON.stringify(this.configData)
318308

319309
if (!node_fs.existsSync(GlobalSettings.USER_CONFIG_DIR)) {
320310
node_fs.mkdirSync(GlobalSettings.USER_CONFIG_DIR)
@@ -324,7 +314,7 @@ class ElectronApp(val url: String) {
324314

325315
fun loaddb() {
326316
if (node_fs.existsSync(GlobalSettings.USER_CONFIG_FILE)) {
327-
var buffer = node_fs.readFileSync(GlobalSettings.USER_CONFIG_FILE)
317+
val buffer = node_fs.readFileSync(GlobalSettings.USER_CONFIG_FILE)
328318
this.configData = JSON.parse(buffer.toString())
329319
}
330320
}

0 commit comments

Comments
 (0)