Skip to content

Commit

Permalink
fix: threaded replies
Browse files Browse the repository at this point in the history
this commit fixes a bug where only the first threaded reply was visible when viewing a threaded discussion
  • Loading branch information
donuts-are-good committed Mar 31, 2023
1 parent 562ff78 commit 06be8dd
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func listReplies(db *sqlx.DB, postNumber int, term *term.Terminal) {
term.Write([]byte(fmt.Sprintf("Replies to post %d [%s]:\n", disc.ID, disc.Author)))

var replies []*reply
err = db.Select(&replies, "SELECT author, message FROM replies WHERE id = ?", postNumber)
err = db.Select(&replies, "SELECT author, message FROM replies WHERE discussion_id = ?", postNumber)
if err != nil {
log.Printf("Error retrieving replies: %v", err)
term.Write([]byte("Error retrieving replies.\n"))
Expand Down Expand Up @@ -337,26 +337,7 @@ makeUsername:
hash = "@" + hash
addUser(hash, &user{Pubkey: pubkey, Hash: hash, Conn: channel})
term := term.NewTerminal(channel, "\r\n> ")
welcome := `
BB BB BB BB BB
,adPPYba, BB,dPPYba, BB,dPPYba, BB,dPPYba, BB,dPPYba, BB,dPPYba,
I8[ "" BBP' "8a BBP' "8a BBP' "8a BBP' "8a BBP' "8a
'"Y8ba, BB BB BB BB BB BB BB d8 BB d8
aa ]8I BB BB BB BB BB BB BBb, ,a8" BBb, ,a8"
'"YbbdP"' BB BB BB BB BB BB 8Y"Ybbd8"' 8Y"Ybbd8"' BBS
> MIT 2023, https://github.com/donuts-are-good/shhhbb v.0.1.1
[RULES] [GOALS]
- your words are your own - a space for hackers & devs
- your eyes are your own - make cool things
- no chat logs are kept - collaborate & share
- have fun :) - evolve
Say hello and press [enter] to chat
Type /help for more commands.
`
welcome := welcomeMessageAscii()
printCachedMessages(term)
term.Write([]byte(welcome))
term.Write([]byte("\nWelcome :) You are " + hash))
Expand Down Expand Up @@ -454,6 +435,30 @@ Type /help for more commands.
}
}

func welcomeMessageAscii() string {
welcome := `
BB BB BB BB BB
,adPPYba, BB,dPPYba, BB,dPPYba, BB,dPPYba, BB,dPPYba, BB,dPPYba,
I8[ "" BBP' "8a BBP' "8a BBP' "8a BBP' "8a BBP' "8a
'"Y8ba, BB BB BB BB BB BB BB d8 BB d8
aa ]8I BB BB BB BB BB BB BBb, ,a8" BBb, ,a8"
'"YbbdP"' BB BB BB BB BB BB 8Y"Ybbd8"' 8Y"Ybbd8"' BBS
> MIT 2023, https://github.com/donuts-are-good/shhhbb v.0.1.2
[RULES] [GOALS]
- your words are your own - a space for hackers & devs
- your eyes are your own - make cool things
- no chat logs are kept - collaborate & share
- have fun :) - evolve
Say hello and press [enter] to chat
Type /help for more commands.
`
return welcome
}

func writeUsersOnline(term *term.Terminal) {
term.Write([]byte("Connected users:\n"))
for _, user := range users {
Expand Down

0 comments on commit 06be8dd

Please sign in to comment.