From 22c952ac7a6cfb5e4fd8ab536cbfef1543b1be91 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Tue, 11 Aug 2020 10:48:13 -0400 Subject: [PATCH] Make dashboard newsfeed list length a configurable item (#12469) Co-authored-by: John Olheiser --- custom/conf/app.example.ini | 2 ++ docs/content/doc/advanced/config-cheat-sheet.en-us.md | 1 + models/action.go | 4 ++-- modules/setting/setting.go | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index a15b9be54f..f8c631ee07 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -164,6 +164,8 @@ EXPLORE_PAGING_NUM = 20 ISSUE_PAGING_NUM = 10 ; Number of maximum commits displayed in one activity feed FEED_MAX_COMMIT_NUM = 5 +; Number of items that are displayed in home feed +FEED_PAGING_NUM = 20 ; Number of maximum commits displayed in commit graph. GRAPH_MAX_COMMIT_NUM = 100 ; Number of line of codes shown for a code comment diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index b659b5daac..39fc350e4f 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -127,6 +127,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`. - `ISSUE_PAGING_NUM`: **10**: Number of issues that are shown in one page (for all pages that list issues). - `MEMBERS_PAGING_NUM`: **20**: Number of members that are shown in organization members. - `FEED_MAX_COMMIT_NUM`: **5**: Number of maximum commits shown in one activity feed. +- `FEED_PAGING_NUM`: **20**: Number of items that are displayed in home feed. - `GRAPH_MAX_COMMIT_NUM`: **100**: Number of maximum commits shown in the commit graph. - `DEFAULT_THEME`: **gitea**: \[gitea, arc-green\]: Set the default theme for the Gitea install. - `THEMES`: **gitea,arc-green**: All available themes. Allow users select personalized themes diff --git a/models/action.go b/models/action.go index d6dbcdc671..f4d163afa3 100644 --- a/models/action.go +++ b/models/action.go @@ -339,9 +339,9 @@ func GetFeeds(opts GetFeedsOptions) ([]*Action, error) { cond = cond.And(builder.Eq{"is_deleted": false}) } - actions := make([]*Action, 0, 20) + actions := make([]*Action, 0, setting.UI.FeedPagingNum) - if err := x.Limit(20).Desc("id").Where(cond).Find(&actions); err != nil { + if err := x.Limit(setting.UI.FeedPagingNum).Desc("id").Where(cond).Find(&actions); err != nil { return nil, fmt.Errorf("Find: %v", err) } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index f4b10feee8..d4ce13079a 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -166,6 +166,7 @@ var ( RepoSearchPagingNum int MembersPagingNum int FeedMaxCommitNum int + FeedPagingNum int GraphMaxCommitNum int CodeCommentLines int ReactionMaxUserNum int @@ -207,6 +208,7 @@ var ( RepoSearchPagingNum: 10, MembersPagingNum: 20, FeedMaxCommitNum: 5, + FeedPagingNum: 20, GraphMaxCommitNum: 100, CodeCommentLines: 4, ReactionMaxUserNum: 10,