about summary refs log tree commit diff stats
path: root/browse-slack
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-13 14:29:27 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-13 14:29:27 -0700
commit8c332c3a151b897b3331d8f1b038f4561d43be89 (patch)
tree113207b477691f0d3d3905cdff74cbfca9a7c6cb /browse-slack
parent32993b205b5a11bf4b91ea51e7ceb133815b5b40 (diff)
downloadmu-8c332c3a151b897b3331d8f1b038f4561d43be89.tar.gz
slack: channel screen: previous post
Diffstat (limited to 'browse-slack')
-rw-r--r--browse-slack/environment.mu19
1 files changed, 18 insertions, 1 deletions
diff --git a/browse-slack/environment.mu b/browse-slack/environment.mu
index fc0e6be2..cb4b96b9 100644
--- a/browse-slack/environment.mu
+++ b/browse-slack/environment.mu
@@ -533,7 +533,7 @@ fn next-item _env: (addr environment), users: (addr array user), channels: (addr
   decrement *dest
 }
 
-fn previous-item _env: (addr environment), users: (addr array user), channels: (addr array channel), _items: (addr item-list) {
+fn previous-item _env: (addr environment), users: (addr array user), _channels: (addr array channel), _items: (addr item-list) {
   var env/edi: (addr environment) <- copy _env
   var tabs-ah/eax: (addr handle array tab) <- get env, tabs
   var _tabs/eax: (addr array tab) <- lookup *tabs-ah
@@ -556,6 +556,23 @@ fn previous-item _env: (addr environment), users: (addr array user), channels: (
     increment *dest
     return
   }
+  compare *current-tab-type, 1/channel
+  {
+    break-if-!=
+    var current-channel-index-addr/eax: (addr int) <- get current-tab, root-index
+    var current-channel-index/eax: int <- copy *current-channel-index-addr
+    var channels/esi: (addr array channel) <- copy _channels
+    var current-channel-offset/eax: (offset channel) <- compute-offset channels, current-channel-index
+    var current-channel/eax: (addr channel) <- index channels, current-channel-offset
+    var current-channel-posts-first-free-addr/eax: (addr int) <- get current-channel, posts-first-free
+    var final-item-index/ecx: int <- copy *current-channel-posts-first-free-addr
+    final-item-index <- decrement
+    var dest/eax: (addr int) <- get current-tab, item-index
+    compare *dest, final-item-index
+    break-if->=
+    increment *dest
+    return
+  }
 }
 
 fn page-down _env: (addr environment), users: (addr array user), channels: (addr array channel), _items: (addr item-list) {