mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 06:42:07 +01:00
Provide webui update timestamp in about webui gql query (#1789)
Makes it possible for the client to determine if a forced page refresh is required to ensure up-to-date webui files are being used
This commit is contained in:
@@ -3,6 +3,7 @@ package suwayomi.tachidesk.graphql.types
|
|||||||
data class AboutWebUI(
|
data class AboutWebUI(
|
||||||
val channel: WebUIChannel,
|
val channel: WebUIChannel,
|
||||||
val tag: String,
|
val tag: String,
|
||||||
|
val updateTimestamp: Long,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class WebUIUpdateCheck(
|
data class WebUIUpdateCheck(
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ object WebInterfaceManager {
|
|||||||
|
|
||||||
private const val LAST_WEBUI_UPDATE_CHECK_KEY = "lastWebUIUpdateCheck"
|
private const val LAST_WEBUI_UPDATE_CHECK_KEY = "lastWebUIUpdateCheck"
|
||||||
private const val SERVED_WEBUI_FLAVOR_KEY = "servedWebUIFlavor"
|
private const val SERVED_WEBUI_FLAVOR_KEY = "servedWebUIFlavor"
|
||||||
|
private const val VERSION_UPDATE_TIMESTAMP_KEY = "webUIVersionUpdateTimestamp"
|
||||||
|
|
||||||
private val preferences = Injekt.get<Application>().getSharedPreferences("server_util", Context.MODE_PRIVATE)
|
private val preferences = Injekt.get<Application>().getSharedPreferences("server_util", Context.MODE_PRIVATE)
|
||||||
private var currentUpdateTaskId: String = ""
|
private var currentUpdateTaskId: String = ""
|
||||||
@@ -141,6 +142,7 @@ object WebInterfaceManager {
|
|||||||
return AboutWebUI(
|
return AboutWebUI(
|
||||||
channel = serverConfig.webUIChannel.value,
|
channel = serverConfig.webUIChannel.value,
|
||||||
tag = currentVersion,
|
tag = currentVersion,
|
||||||
|
updateTimestamp = preferences.getLong(VERSION_UPDATE_TIMESTAMP_KEY, System.currentTimeMillis()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,6 +478,7 @@ object WebInterfaceManager {
|
|||||||
log.info { "An update is available, starting download..." }
|
log.info { "An update is available, starting download..." }
|
||||||
try {
|
try {
|
||||||
downloadVersion(flavor, getLatestCompatibleVersion(flavor))
|
downloadVersion(flavor, getLatestCompatibleVersion(flavor))
|
||||||
|
preferences.edit().putLong(VERSION_UPDATE_TIMESTAMP_KEY, System.currentTimeMillis()).apply()
|
||||||
serveWebUI()
|
serveWebUI()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
log.warn(e) { "failed due to" }
|
log.warn(e) { "failed due to" }
|
||||||
|
|||||||
Reference in New Issue
Block a user