mirror of
https://git.sr.ht/~oppen/ariane
synced 2024-12-27 02:10:30 +00:00
reestablish working history now tabs are removed
This commit is contained in:
parent
55b0797612
commit
053935e879
1 changed files with 17 additions and 4 deletions
|
@ -10,11 +10,8 @@ class TvaViewModel: ViewModel() {
|
||||||
|
|
||||||
private lateinit var gemini: Datasource
|
private lateinit var gemini: Datasource
|
||||||
private var onState: (state: TvaState) -> Unit = {}
|
private var onState: (state: TvaState) -> Unit = {}
|
||||||
private var activeTab = 0
|
|
||||||
|
|
||||||
val history = mutableListOf<URI>()
|
|
||||||
|
|
||||||
|
|
||||||
|
private val history = mutableListOf<URI>()
|
||||||
|
|
||||||
fun initialise(gemini: Datasource, onState: (state: TvaState) -> Unit){
|
fun initialise(gemini: Datasource, onState: (state: TvaState) -> Unit){
|
||||||
this.gemini = gemini
|
this.gemini = gemini
|
||||||
|
@ -30,6 +27,11 @@ class TvaViewModel: ViewModel() {
|
||||||
|
|
||||||
fun request(uri: URI){
|
fun request(uri: URI){
|
||||||
gemini.request(uri){ state ->
|
gemini.request(uri){ state ->
|
||||||
|
if(history.isEmpty()){
|
||||||
|
history.add(uri)
|
||||||
|
}else if(history.last().toString() != uri.toString()) {
|
||||||
|
history.add(uri)
|
||||||
|
}
|
||||||
onState(state)
|
onState(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,11 +41,22 @@ class TvaViewModel: ViewModel() {
|
||||||
@ExperimentalStdlibApi
|
@ExperimentalStdlibApi
|
||||||
fun goBack(){
|
fun goBack(){
|
||||||
when {
|
when {
|
||||||
|
|
||||||
history.size >= 2 -> {
|
history.size >= 2 -> {
|
||||||
|
logHistory()
|
||||||
val previous = history[history.size - 2]
|
val previous = history[history.size - 2]
|
||||||
history.removeLast()
|
history.removeLast()
|
||||||
|
|
||||||
|
println("Requesting history item: $previous")
|
||||||
request(previous)
|
request(previous)
|
||||||
|
logHistory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun logHistory(){
|
||||||
|
history.forEach { uri ->
|
||||||
|
println("History: $uri")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue