import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.PostReply
import net.pterodactylus.sone.data.Sone
import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.PostReply
import net.pterodactylus.sone.data.Sone
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.FreenetRequest
import java.text.SimpleDateFormat
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.FreenetRequest
import java.text.SimpleDateFormat
/**
* The “get status” AJAX handler returns all information that is necessary to
* update the web interface in real-time.
*/
/**
* The “get status” AJAX handler returns all information that is necessary to
* update the web interface in real-time.
*/
-class GetStatusAjaxPage(webInterface: WebInterface, private val timeTextConverter: TimeTextConverter, private val l10nFilter: L10nFilter):
+class GetStatusAjaxPage(webInterface: WebInterface, private val elementLoader: ElementLoader, private val timeTextConverter: TimeTextConverter, private val l10nFilter: L10nFilter, timeZone: TimeZone = TimeZone.getDefault()):
- private val dateFormatter = SimpleDateFormat("MMM d, yyyy, HH:mm:ss")
+ private val dateFormatter = SimpleDateFormat("MMM d, yyyy, HH:mm:ss").apply {
+ this.timeZone = timeZone
+ }
createSuccessJsonObject().apply {
this["loggedIn"] = currentSone != null
this["options"] = currentSone?.options?.toJsonOptions() ?: jsonObject {}
createSuccessJsonObject().apply {
this["loggedIn"] = currentSone != null
this["options"] = currentSone?.options?.toJsonOptions() ?: jsonObject {}
this["sones"] = request.httpRequest.getParam("soneIds").split(',').map { webInterface.core.getSone(it).orNull() }.plus(currentSone).filterNotNull().toJsonSones()
this["newPosts"] = webInterface.getNewPosts(currentSone).toJsonPosts()
this["newReplies"] = webInterface.getNewReplies(currentSone).toJsonReplies()
this["sones"] = request.httpRequest.getParam("soneIds").split(',').map { webInterface.core.getSone(it).orNull() }.plus(currentSone).filterNotNull().toJsonSones()
this["newPosts"] = webInterface.getNewPosts(currentSone).toJsonPosts()
this["newReplies"] = webInterface.getNewReplies(currentSone).toJsonReplies()
private operator fun JsonReturnObject.set(key: String, value: Int) = put(key, value)
private operator fun JsonReturnObject.set(key: String, value: Boolean) = put(key, value)
private operator fun JsonReturnObject.set(key: String, value: Int) = put(key, value)
private operator fun JsonReturnObject.set(key: String, value: Boolean) = put(key, value)