Skip to content

Commit e8fba1f

Browse files
committed
refactor user.retriveFeeds
1 parent 7dcb601 commit e8fba1f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

routers/web/user/home.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ func getDashboardContextUser(ctx *context.Context) *models.User {
5959
}
6060

6161
// retrieveFeeds loads feeds for the specified user
62-
func retrieveFeeds(ctx *context.Context, options models.GetFeedsOptions) {
62+
func retrieveFeeds(ctx *context.Context, options models.GetFeedsOptions) []*models.Action {
6363
actions, err := models.GetFeeds(options)
6464
if err != nil {
6565
ctx.ServerError("GetFeeds", err)
66-
return
66+
return nil
6767
}
6868

6969
userCache := map[int64]*models.User{options.RequestedUser.ID: options.RequestedUser}
@@ -85,13 +85,13 @@ func retrieveFeeds(ctx *context.Context, options models.GetFeedsOptions) {
8585
continue
8686
}
8787
ctx.ServerError("GetUserByID", err)
88-
return
88+
return nil
8989
}
9090
userCache[repoOwner.ID] = repoOwner
9191
}
9292
act.Repo.Owner = repoOwner
9393
}
94-
ctx.Data["Feeds"] = actions
94+
return actions
9595
}
9696

9797
// Dashboard render the dashboard page
@@ -149,7 +149,7 @@ func Dashboard(ctx *context.Context) {
149149
ctx.Data["MirrorCount"] = len(mirrors)
150150
ctx.Data["Mirrors"] = mirrors
151151

152-
retrieveFeeds(ctx, models.GetFeedsOptions{
152+
actions := retrieveFeeds(ctx, models.GetFeedsOptions{
153153
RequestedUser: ctxUser,
154154
RequestedTeam: ctx.Org.Team,
155155
Actor: ctx.User,
@@ -158,10 +158,11 @@ func Dashboard(ctx *context.Context) {
158158
IncludeDeleted: false,
159159
Date: ctx.Query("date"),
160160
})
161-
162161
if ctx.Written() {
163162
return
164163
}
164+
ctx.Data["Feeds"] = actions
165+
165166
ctx.HTML(http.StatusOK, tplDashboard)
166167
}
167168

routers/web/user/profile.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func Profile(ctx *context.Context) {
208208

209209
total = ctxUser.NumFollowing
210210
case "activity":
211-
retrieveFeeds(ctx, models.GetFeedsOptions{RequestedUser: ctxUser,
211+
actions := retrieveFeeds(ctx, models.GetFeedsOptions{RequestedUser: ctxUser,
212212
Actor: ctx.User,
213213
IncludePrivate: showPrivate,
214214
OnlyPerformedBy: true,
@@ -218,6 +218,7 @@ func Profile(ctx *context.Context) {
218218
if ctx.Written() {
219219
return
220220
}
221+
ctx.Data["Feeds"] = actions
221222
case "stars":
222223
ctx.Data["PageIsProfileStarList"] = true
223224
repos, count, err = models.SearchRepository(&models.SearchRepoOptions{

0 commit comments

Comments
 (0)