From 066d6aaf2c3815aa466d1c115e403c57f6508126 Mon Sep 17 00:00:00 2001 From: Ryan Stafford Date: Fri, 10 May 2024 11:07:59 -0400 Subject: [PATCH] user overview post process --- state.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/state.go b/state.go index 3d86931..8dd2d27 100644 --- a/state.go +++ b/state.go @@ -503,6 +503,13 @@ func (state *State) GetUser(username string) { if state.Query != "" { return } + for _, c := range resp.Comments { + comment := Comment{P: c, State: state} + state.Activities = append(state.Activities, Activity{ + Timestamp: c.Comment.Published, + Comment: &comment, + }) + } for i, p := range resp.Posts { post := Post{ PostView: resp.Posts[i], @@ -514,15 +521,15 @@ func (state *State) GetUser(username string) { Post: &post, }) } - for _, c := range resp.Comments { - comment := Comment{P: c, State: state} - state.Activities = append(state.Activities, Activity{ - Timestamp: c.Comment.Published, - Comment: &comment, - }) - } sort.Slice(state.Activities, func(i, j int) bool { - return state.Activities[i].Timestamp.After(state.Activities[j].Timestamp.Time) + switch state.Sort { + case "New": + return state.Activities[i].Timestamp.After(state.Activities[j].Timestamp.Time) + case "Old": + return state.Activities[i].Timestamp.Before(state.Activities[j].Timestamp.Time) + } + // TODO Top and Controversial + return false }) }