Skip to content

Commit

Permalink
chore: change flag item function to receive threshold as arg
Browse files Browse the repository at this point in the history
  • Loading branch information
jeronimoalbi committed Feb 13, 2025
1 parent 97eaca7 commit 44e6587
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions examples/gno.land/r/nt/boards2/v1/flag.gno
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ type Flaggable interface {
// Returns whether flag count threshold is reached and item can be hidden.
//
// Panics if flag count threshold was already reached.
func flagItem(bid BoardID, item Flaggable, flag Flag) bool {
threshold := getFlaggingThreshold(bid)
func flagItem(item Flaggable, flag Flag, threshold int) bool {
if item.FlagsCount() >= threshold {
panic("item flag count threshold exceeded: " + strconv.Itoa(threshold))
}
Expand Down
6 changes: 4 additions & 2 deletions examples/gno.land/r/nt/boards2/v1/public.gno
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func FlagThread(bid BoardID, postID PostID, reason string) {
panic("post doesn't exist")
}

hide := flagItem(board.id, t, NewFlag(caller, reason))
threshold := getFlaggingThreshold(bid)
hide := flagItem(t, NewFlag(caller, reason), threshold)
if hide {
t.SetVisible(false)
}
Expand Down Expand Up @@ -144,7 +145,8 @@ func FlagReply(bid BoardID, threadID, replyID PostID, reason string) {
thread := mustGetThread(board, threadID)
reply := mustGetReply(thread, replyID)

hide := flagItem(board.id, reply, NewFlag(caller, reason))
threshold := getFlaggingThreshold(bid)
hide := flagItem(reply, NewFlag(caller, reason), threshold)
if hide {
reply.SetVisible(false)
}
Expand Down

0 comments on commit 44e6587

Please sign in to comment.