mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-08 08:04:26 +00:00
user overview post process
This commit is contained in:
parent
944afd7d59
commit
066d6aaf2c
21
state.go
21
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 {
|
||||
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
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue