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

chore: Revert PR 25: Remove the debugNow hack #143

Merged
merged 1 commit into from
Dec 9, 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
15 changes: 1 addition & 14 deletions realm/post.gno
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"gno.land/p/moul/txlink"
)

var debugNowOffset time.Duration

//----------------------------------------
// Post

Expand Down Expand Up @@ -62,7 +60,7 @@ func newPost(userPosts *UserPosts, id PostID, creator std.Address, body string,
parentID: parentID,
repostUser: repostUser,
reactions: avl.NewTree(),
createdAt: debugNow(),
createdAt: time.Now(),
}
}

Expand Down Expand Up @@ -322,14 +320,3 @@ func getPosts(posts avl.Tree, startIndex int, endIndex int) string {
json += "]}"
return json
}

// Until the problem explained in https://github.com/gnolang/gno/issues/1509
// is solved, we need post timestamps to be different on reload. This
// calls Time.Now() and adds an offset which increases by one minute on each call.
// Therefore, in "normal" operation (before reload) the times are close to the
// expected value. After reload, all times will be the time of reload, increasing by
// one minute each, which is not ideal but at least they are different and in order.
func debugNow() time.Time {
debugNowOffset += time.Minute
return time.Now().Add(debugNowOffset)
}
2 changes: 1 addition & 1 deletion realm/userposts.gno
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (userPosts *UserPosts) Follow(followedAddr std.Address) PostID {
followedUserPosts := getUserPosts(followedAddr)
if followedUserPosts != nil {
userPosts.following.Set(followedAddr.String(), &FollowingInfo{
startedFollowingAt: debugNow(),
startedFollowingAt: time.Now(),
startedPostsCtr: PostID(postsCtr), // Ignore past messages.
})
followedUserPosts.followers.Set(userPosts.userAddr.String(), "")
Expand Down