mirror of
https://git.sr.ht/~oppen/ariane
synced 2024-12-26 17:59: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 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){
|
||||
this.gemini = gemini
|
||||
|
@ -30,6 +27,11 @@ class TvaViewModel: ViewModel() {
|
|||
|
||||
fun request(uri: URI){
|
||||
gemini.request(uri){ state ->
|
||||
if(history.isEmpty()){
|
||||
history.add(uri)
|
||||
}else if(history.last().toString() != uri.toString()) {
|
||||
history.add(uri)
|
||||
}
|
||||
onState(state)
|
||||
}
|
||||
}
|
||||
|
@ -39,11 +41,22 @@ class TvaViewModel: ViewModel() {
|
|||
@ExperimentalStdlibApi
|
||||
fun goBack(){
|
||||
when {
|
||||
|
||||
history.size >= 2 -> {
|
||||
logHistory()
|
||||
val previous = history[history.size - 2]
|
||||
history.removeLast()
|
||||
|
||||
println("Requesting history item: $previous")
|
||||
request(previous)
|
||||
logHistory()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun logHistory(){
|
||||
history.forEach { uri ->
|
||||
println("History: $uri")
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue