shithub: hell

Download patch

ref: 73c533fd15674bab9fa0b33e1a133a9b91e812f7
parent: 976dbaad5ce07c999268da84ca691e4098517b06
author: penny <penny@limitedideas.org>
date: Wed Sep 10 18:19:11 EDT 2025

Improved read since

--- a/hellclient.go
+++ b/hellclient.go
@@ -4,10 +4,11 @@
 	"context"
 	"fmt"
 	"io"
+	"log"
+	"os"
 	"strings"
 	"sync"
 	"time"
-	"os"
 
 	"github.com/ergochat/readline"
 	"github.com/mattn/go-mastodon"
@@ -66,7 +67,7 @@
 	config := &readline.Config{
 		Prompt: "Hell> ",
 		FuncFilterInputRune: func(r rune) (rune, bool) {
-			if r == readline.CharCtrlJ { // ctrl-j
+			if r == readline.CharCtrlJ {
 				hc.multiLineMode = !hc.multiLineMode
 				hc.updatePrompt()
 				return r, false
@@ -93,9 +94,7 @@
 					return nil, 0, true
 				}
 				os.Exit(0)
-				return []rune("Goodbye!\n"), 0, true
 			}
-			
 			return nil, 0, false
 		},
 	}
@@ -103,6 +102,7 @@
 	if err != nil {
 		return nil, err
 	}
+	
 
 	account, err := loadConfig()
 	if err != nil {
@@ -128,16 +128,42 @@
 		}
 
 		initReferenceSystem()
-
-		LastID := markers["home"].LastID
-		page := &mastodon.Pagination{SinceID: LastID}
+		
+		lastReadID := markers["home"].LastID
+		var page *mastodon.Pagination
 		statuses, err := hc.client.GetTimelineHome(context.Background(), page)
-		for _, status := range statuses {
-			hc.printPost("?" + hc.ctxref.ref, status)
-			saveRef(hc.ctxref.postmap, status, "?" + hc.ctxref.ref)
-			hc.ctxref.ref = IncrementString(hc.ctxref.ref)
-			continue
+		maxID := statuses[0].ID
+		if err != nil {
+			return
 		}
+		page = &mastodon.Pagination{MinID: lastReadID}
+		if len(statuses) > 0 {
+			markers["home"].Timeline = "home"
+			markers["home"].ID = maxID
+			homemarker := markers["home"]
+			hc.client.SetTimelineMarkers(context.Background(), &[]mastodon.Marker{*homemarker})
+		}
+		for {
+			statuses, err := hc.client.GetTimelineHome(context.Background(), page)
+			if err != nil {
+				log.Printf("error fetching timeline: %v", err)
+				break
+			}
+			if len(statuses) == 0 {
+				break
+			}
+
+			// Reverse the statuses to print them in chronological order
+			for i := len(statuses) - 1; i >= 0; i-- {
+				status := statuses[i]
+				hc.printPost("?"+hc.ctxref.ref, status)
+				saveRef(hc.ctxref.postmap, status, "?"+hc.ctxref.ref)
+				hc.ctxref.ref = IncrementString(hc.ctxref.ref)
+			}
+			//I really don't understand the server's results but erase the max ID and it paginates up I don't know man
+			page.MaxID = ""
+			time.Sleep(1 * time.Second)
+		}
 		}()
 
 	homeMap := make(map[string]*mastodon.Status)
@@ -217,3 +243,6 @@
 func (hc *Hellclient) unlock() {
 	hc.block.Unlock()
 }
+
+
+
--