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(
|
||||
val channel: WebUIChannel,
|
||||
val tag: String,
|
||||
val updateTimestamp: Long,
|
||||
)
|
||||
|
||||
data class WebUIUpdateCheck(
|
||||
|
||||
@@ -84,6 +84,7 @@ object WebInterfaceManager {
|
||||
|
||||
private const val LAST_WEBUI_UPDATE_CHECK_KEY = "lastWebUIUpdateCheck"
|
||||
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 var currentUpdateTaskId: String = ""
|
||||
@@ -141,6 +142,7 @@ object WebInterfaceManager {
|
||||
return AboutWebUI(
|
||||
channel = serverConfig.webUIChannel.value,
|
||||
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..." }
|
||||
try {
|
||||
downloadVersion(flavor, getLatestCompatibleVersion(flavor))
|
||||
preferences.edit().putLong(VERSION_UPDATE_TIMESTAMP_KEY, System.currentTimeMillis()).apply()
|
||||
serveWebUI()
|
||||
} catch (e: Exception) {
|
||||
log.warn(e) { "failed due to" }
|
||||
|
||||
Reference in New Issue
Block a user