Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Access the User struct Name and Address without the getter method #31

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion realm/public.gno
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func GetUsers() *avl.Tree {
gUserPostsByAddress.Iterate("", "", func(addr string, userPostsI interface{}) bool {
if user := users.GetUserByAddress(std.Address(addr)); user != nil {
// allUsers will be sorted by the name key.
allUsers.Set(user.Name(), addr)
allUsers.Set(user.Name, addr)
}
return false
})
Expand Down
8 changes: 4 additions & 4 deletions realm/render.gno
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Render(path string) string {
names := []string{}
gUserPostsByAddress.Iterate("", "", func(key string, value interface{}) bool {
if user := users.GetUserByAddress(std.Address(key)); user != nil {
names = append(names, user.Name())
names = append(names, user.Name)
}
return false
})
Expand All @@ -37,7 +37,7 @@ func Render(path string) string {
return "Unknown user: " + path
}

userPosts := getUserPosts(user.Address())
userPosts := getUserPosts(user.Address)
if userPosts == nil {
return "No posts by: " + path
}
Expand All @@ -49,7 +49,7 @@ func Render(path string) string {
if user == nil {
return "Unknown user: " + name
}
userPosts := getUserPosts(user.Address())
userPosts := getUserPosts(user.Address)
if userPosts == nil {
return "No posts by: " + name
}
Expand Down Expand Up @@ -82,7 +82,7 @@ func Render(path string) string {
if user == nil {
return "Unknown user: " + name
}
userPosts := getUserPosts(user.Address())
userPosts := getUserPosts(user.Address)
if userPosts == nil {
return "No posts by: " + name
}
Expand Down
12 changes: 6 additions & 6 deletions realm/userposts.gno
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func (userPosts *UserPosts) RenderUserPosts(includeFollowed bool) string {
following := "Following " + strconv.Itoa(userPosts.following.Size())
user := users.GetUserByAddress(userPosts.userAddr)
if user != nil {
followers = "[" + followers + "](/r/berty/social:" + user.Name() + "/followers)"
following = "[" + following + "](/r/berty/social:" + user.Name() + "/following)"
followers = "[" + followers + "](/r/berty/social:" + user.Name + "/followers)"
following = "[" + following + "](/r/berty/social:" + user.Name + "/following)"
}
str += followers + "  " + following + "\n\n"

Expand Down Expand Up @@ -122,15 +122,15 @@ func (userPosts *UserPosts) RenderFollowers() string {
str := ""
user := users.GetUserByAddress(userPosts.userAddr)
if user != nil {
str += "[@" + user.Name() + "](/r/berty/social:" + user.Name() + ") "
str += "[@" + user.Name + "](/r/berty/social:" + user.Name + ") "
}
str += "Followers\n\n"

// List the followers, sorted by name.
names := []string{}
userPosts.followers.Iterate("", "", func(key string, value interface{}) bool {
if user := users.GetUserByAddress(std.Address(key)); user != nil {
names = append(names, user.Name())
names = append(names, user.Name)
}
return false
})
Expand All @@ -146,7 +146,7 @@ func (userPosts *UserPosts) RenderFollowing() string {
str := ""
user := users.GetUserByAddress(userPosts.userAddr)
if user != nil {
str += "[@" + user.Name() + "](/r/berty/social:" + user.Name() + ") "
str += "[@" + user.Name + "](/r/berty/social:" + user.Name + ") "
}
str += "Following\n\n"

Expand All @@ -155,7 +155,7 @@ func (userPosts *UserPosts) RenderFollowing() string {
userPosts.following.Iterate("", "", func(addr string, infoI interface{}) bool {
info := infoI.(*FollowingInfo)
if user := users.GetUserByAddress(std.Address(addr)); user != nil {
nameAddrs = append(nameAddrs, user.Name()+"/"+addr+"/"+info.startedFollowingAt.Format("2006-01-02"))
nameAddrs = append(nameAddrs, user.Name+"/"+addr+"/"+info.startedFollowingAt.Format("2006-01-02"))
}
return false
})
Expand Down
4 changes: 2 additions & 2 deletions realm/util.gno
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func displayAddressMD(addr std.Address) string {
if user == nil {
return "[" + addr.String() + "](/r/demo/users:" + addr.String() + ")"
} else {
return "[@" + user.Name() + "](/r/berty/social:" + user.Name() + ")"
return "[@" + user.Name + "](/r/berty/social:" + user.Name + ")"
}
}

Expand All @@ -73,6 +73,6 @@ func usernameOf(addr std.Address) string {
if user == nil {
return ""
} else {
return user.Name()
return user.Name
}
}