0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-15 03:01:37 -05:00

Fixed Loading state for sidebar suggestions (#22789)

Ref
https://linear.app/ghost/issue/AP-1025/loading-state-for-stuck-for-sidebar-suggestions
This commit is contained in:
Princi Vershwal 2025-04-03 16:13:51 +05:30 committed by GitHub
parent 312f86fdb7
commit 9ceb3ead7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 15 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@tryghost/admin-x-activitypub",
"version": "0.6.30",
"version": "0.6.31",
"license": "MIT",
"repository": {
"type": "git",

View file

@ -10,13 +10,11 @@ import {useSuggestedProfilesForUser} from '@hooks/use-activity-pub-queries';
const Recommendations: React.FC = () => {
const {suggestedProfilesQuery} = useSuggestedProfilesForUser('index', 3);
const {data: suggestedData, isLoading: isLoadingSuggested} = suggestedProfilesQuery;
const suggested = suggestedData || Array(3).fill({id: '', name: '', handle: '', avatarUrl: '', bio: '', followerCount: 0, followingCount: 0, followedByMe: false});
const suggested = isLoadingSuggested ? Array(3).fill(null) : (suggestedData || []);
const navigate = useNavigate();
const {isEnabled} = useFeatureFlags();
const {resetStack} = useNavigationStack();
let i = 0;
const hideClassName = '[@media(max-height:740px)]:hidden';
return (
@ -31,13 +29,13 @@ const Recommendations: React.FC = () => {
</span>
</div>
<ul className='grow'>
{suggested.map((profile) => {
const actorId = profile.id;
const actorName = profile.name;
const actorHandle = profile.handle;
const actorAvatarUrl = profile.avatarUrl;
{suggested.map((profile, index) => {
const actorId = profile?.id || `loading-${index}`;
const actorName = profile?.name || '';
const actorHandle = profile?.handle || '';
const actorAvatarUrl = profile?.avatarUrl || '';
let className;
switch (i) {
switch (index) {
case 0:
className = '[@media(max-height:740px)]:hidden';
break;
@ -48,16 +46,17 @@ const Recommendations: React.FC = () => {
className = '[@media(max-height:860px)]:hidden';
break;
}
i = i + 1;
return (
<React.Fragment key={actorId}>
<li key={actorId} className={className}>
<ActivityItem onClick={() => {
if (isEnabled('ap-routes')) {
handleProfileClickRR(actorHandle, navigate);
} else {
handleProfileClick(actorHandle);
if (!isLoadingSuggested && profile) {
if (isEnabled('ap-routes')) {
handleProfileClickRR(actorHandle, navigate);
} else {
handleProfileClick(actorHandle);
}
}
}}>
{!isLoadingSuggested ? <APAvatar author={