Skip to content

Commit

Permalink
fix: In realm code, use txlink.URL. See the PR.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Thompson <[email protected]>
  • Loading branch information
jefft0 committed Nov 14, 2024
1 parent dac561c commit dedfb06
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
29 changes: 14 additions & 15 deletions realm/post.gno
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"gno.land/p/demo/avl"
"gno.land/p/demo/ufmt"
"gno.land/p/moul/txlink"
)

var debugNowOffset time.Duration
Expand Down Expand Up @@ -182,27 +183,25 @@ func (post *Post) GetURL() string {
}

func (post *Post) GetGnodFormURL() string {
return "/r/berty/social?help&__func=AddReaction" +
"&userPostsAddr=" + post.userPosts.userAddr.String() +
"&threadid=" + post.threadID.String() +
"&postid=" + post.id.String() +
"&reaction=" + strconv.Itoa(int(Gnod))
return txlink.URL("AddReaction",
"userPostsAddr", post.userPosts.userAddr.String(),
"threadid", post.threadID.String(),
"postid", post.id.String(),
"reaction", strconv.Itoa(int(Gnod)))
}

func (post *Post) GetReplyFormURL() string {
return "/r/berty/social?help&__func=PostReply" +
"&userPostsAddr=" + post.userPosts.userAddr.String() +
"&threadid=" + post.threadID.String() +
"&postid=" + post.id.String() +
"&comment.type=textarea"
return txlink.URL("PostReply",
"userPostsAddr", post.userPosts.userAddr.String(),
"threadid", post.threadID.String(),
"postid", post.id.String())
}

func (post *Post) GetRepostFormURL() string {
return "/r/berty/social?help&__func=RepostThread" +
"&userPostsAddr=" + post.userPosts.userAddr.String() +
"&threadid=" + post.threadID.String() +
"&postid=" + post.id.String() +
"&body.type=textarea"
return txlink.URL("RepostThread",
"userPostsAddr", post.userPosts.userAddr.String(),
"threadid", post.threadID.String(),
"postid", post.id.String())
}

func (post *Post) RenderSummary() string {
Expand Down
13 changes: 5 additions & 8 deletions realm/userposts.gno
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"gno.land/p/demo/avl"
"gno.land/p/demo/ufmt"
"gno.land/p/moul/txlink"
"gno.land/r/demo/users"
)

Expand Down Expand Up @@ -208,23 +209,19 @@ func (userPosts *UserPosts) GetURLFromThreadAndReplyID(threadID, replyID PostID)
}

func (userPosts *UserPosts) GetPostFormURL() string {
return "/r/berty/social?help&__func=PostMessage" +
"&body.type=textarea"
return txlink.URL("PostMessage")
}

func (userPosts *UserPosts) GetFollowFormURL() string {
return "/r/berty/social?help&__func=Follow" +
"&followedAddr=" + userPosts.userAddr.String()
return txlink.URL("Follow", "followedAddr", userPosts.userAddr.String())
}

func (userPosts *UserPosts) GetUnfollowFormURL(followedAddr std.Address) string {
return "/r/berty/social?help&__func=Unfollow" +
"&followedAddr=" + followedAddr.String()
return txlink.URL("Unfollow", "followedAddr", followedAddr.String())
}

func (userPosts *UserPosts) GetRefreshFormURL() string {
return "/r/berty/social?help&__func=RefreshHomePosts" +
"&userPostsAddr=" + userPosts.userAddr.String()
return txlink.URL("RefreshHomePosts", "userPostsAddr", userPosts.userAddr.String())
}

// Scan userPosts.following for all posts from all followed users starting from lastRefreshId+1 .
Expand Down

0 comments on commit dedfb06

Please sign in to comment.