feat(ui): messages for empty usercards (#7947)

Show a message about list being empty, so the page doesn't look broken-ish empty.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7947
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: Otto <otto@codeberg.org>
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Co-committed-by: 0ko <0ko@noreply.codeberg.org>
This commit is contained in:
0ko 2025-05-23 23:34:40 +02:00 committed by Otto
parent 2b30c83a0c
commit 765e7bd1b6
6 changed files with 74 additions and 30 deletions

View file

@ -1,5 +1,6 @@
// Copyright 2015 The Gogs Authors. All rights reserved.
// Copyright 2019 The Gitea Authors. All rights reserved.
// Copyright 2023 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package user
@ -170,10 +171,20 @@ func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileDb
ctx.Data["Cards"] = followers
total = int(numFollowers)
ctx.Data["CardsTitle"] = ctx.TrN(total, "user.followers.title.one", "user.followers.title.few")
if ctx.IsSigned && ctx.ContextUser.ID == ctx.Doer.ID {
ctx.Data["CardsNoneMsg"] = ctx.Tr("followers.incoming.list.self.none")
} else {
ctx.Data["CardsNoneMsg"] = ctx.Tr("followers.incoming.list.none")
}
case "following":
ctx.Data["Cards"] = following
total = int(numFollowing)
ctx.Data["CardsTitle"] = ctx.TrN(total, "user.following.title.one", "user.following.title.few")
if ctx.IsSigned && ctx.ContextUser.ID == ctx.Doer.ID {
ctx.Data["CardsNoneMsg"] = ctx.Tr("followers.outgoing.list.self.none")
} else {
ctx.Data["CardsNoneMsg"] = ctx.Tr("followers.outgoing.list.none", ctx.ContextUser.Name)
}
case "activity":
date := ctx.FormString("date")
pagingNum = setting.UI.FeedPagingNum