mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-25 14:49:07 +00:00
user overview post process
This commit is contained in:
parent
944afd7d59
commit
066d6aaf2c
23
state.go
23
state.go
|
@ -503,6 +503,13 @@ func (state *State) GetUser(username string) {
|
||||||
if state.Query != "" {
|
if state.Query != "" {
|
||||||
return
|
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 {
|
for i, p := range resp.Posts {
|
||||||
post := Post{
|
post := Post{
|
||||||
PostView: resp.Posts[i],
|
PostView: resp.Posts[i],
|
||||||
|
@ -514,15 +521,15 @@ func (state *State) GetUser(username string) {
|
||||||
Post: &post,
|
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 {
|
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
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue