fix scrooling users issue and added some fixes

This commit is contained in:
shinya 2025-08-19 13:57:21 +02:00
parent 345fab6a32
commit 64503b7281
6 changed files with 36 additions and 31 deletions

BIN
configs/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -1,26 +1,25 @@
{ {
"messages" : "messages": [
[
{ {
"id": "1", "id": "1",
"sender": "Bob", "sender": "Bob",
"receiver": "Filip", "receiver": "Filip",
"content": "SGVsbG8gQm9iLCBob3cgYXJlIHlvdT8K", "content": "QWhvaiBGw61sbywgZGxvdWhvIGpzbWUgc2UgbmV2aWTEm2xpIPCfmJoK",
"timestamp": "2023-10-01T10:00:00Z" "timestamp": "2024-07-10T11:07:00Z"
}, },
{ {
"id": "2", "id": "2",
"sender": "Filip", "sender": "Filip",
"receiver": "Bob", "receiver": "Bob",
"content": "SGkgQWxpY2UhIEknbSBkb2luZyB3ZWxsLCB0aGFua3MuIEhvdyBhYm91dCB5b3U/Cg==", "content": "xIxhdWt5eXksIG1vaGxpIGJ5Y2hvbSB6YXNlIG7Em2tkeSB1ZMSbbGF0IHNyYXoK",
"timestamp": "2023-10-01T10:05:00Z" "timestamp": "2024-07-10T11:18:00Z"
}, },
{ {
"id": "3", "id": "3",
"sender": "Bob", "sender": "Bob",
"receiver": "FIlip", "receiver": "Filip",
"content": "SSdtIGdyZWF0LCB0aGFua3MgZm9yIGFza2luZwo=", "content": "VG8gYnljaG9tIG1vaGxpLCB2eWhvdnVqZSB0aSB0ZW5obGUgdMO9ZGVuIHZlIHN0xZllZHU/Cg==",
"timestamp": "2023-10-01T10:06:00Z" "timestamp": "2024-10-01T11:23:00Z"
} }
] ]
} }

5
examples/config.json Normal file
View File

@ -0,0 +1,5 @@
{
"app_name": "WhspBrd",
"version": "0.1.0",
"username": "${USERNAME}"
}

View File

@ -1,4 +1,4 @@
package config package main
import ( import (
"embed" "embed"

View File

@ -19,6 +19,7 @@ func layout(g *gocui.Gui) error {
return err return err
} }
if err := layoutChat(g, maxX, maxY); err != nil { if err := layoutChat(g, maxX, maxY); err != nil {
//updateChatView(g.Views()[1])
return err return err
} }
if err := layoutInput(g, maxX, maxY); err != nil { if err := layoutInput(g, maxX, maxY); err != nil {

View File

@ -6,9 +6,7 @@ import (
"github.com/jroimartin/gocui" "github.com/jroimartin/gocui"
) )
var selectedUserIdx int var selectedUserIdx int = 0
//!FIX: First selected contact don't work only second selected is working ok
// LAYOUT // LAYOUT
func layoutSidebar(g *gocui.Gui, maxY int) error { func layoutSidebar(g *gocui.Gui, maxY int) error {
@ -60,8 +58,9 @@ func nextContact(g *gocui.Gui, v *gocui.View) error {
return nil return nil
} }
selectedUserIdx = (selectedUserIdx + 1) % len(users) selectedUserIdx = (selectedUserIdx + 1) % len(users)
err := updateUsersView(g)
updateChatView(g.Views()[1]) updateChatView(g.Views()[1])
return updateUsersView(g) return err
} }
func prevContact(g *gocui.Gui, v *gocui.View) error { func prevContact(g *gocui.Gui, v *gocui.View) error {
@ -69,6 +68,7 @@ func prevContact(g *gocui.Gui, v *gocui.View) error {
return nil return nil
} }
selectedUserIdx = (selectedUserIdx - 1 + len(users)) % len(users) selectedUserIdx = (selectedUserIdx - 1 + len(users)) % len(users)
err := updateUsersView(g)
updateChatView(g.Views()[1]) updateChatView(g.Views()[1])
return updateUsersView(g) return err
} }