Skip to content

Commit

Permalink
🐛 fix: Fix changelog fetch fail (fix lobehub#5187) (lobehub#5189)
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 authored Dec 26, 2024
1 parent 26216ce commit 5ad66a6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/app/(main)/changelog/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const Page = async () => {
const changelogService = new ChangelogService();
const data = await changelogService.getChangelogIndex();

if (!data) return notFound();

const ld = ldModule.generate({
description: t('changelog.description', { appName: BRANDING_NAME }),
title: t('changelog.title', { appName: BRANDING_NAME }),
Expand All @@ -48,7 +50,7 @@ const Page = async () => {
<>
<StructuredData ld={ld} />
<Flexbox gap={mobile ? 16 : 48}>
{data.map((item) => (
{data?.map((item) => (
<Fragment key={item.id}>
<Suspense
fallback={
Expand Down
4 changes: 3 additions & 1 deletion src/app/@modal/(.)changelog/modal/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ const Page = async () => {
const changelogService = new ChangelogService();
const data = await changelogService.getChangelogIndex();

if (!data) return notFound();

return (
<>
{data.map((item) => (
{data?.map((item) => (
<Suspense fallback={<Loading />} key={item.id}>
<Post locale={locale} mobile={mobile} {...item} />
</Suspense>
Expand Down
10 changes: 8 additions & 2 deletions src/features/ChangelogModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ import { memo } from 'react';
import { useGlobalStore } from '@/store/global';

const ChangelogModal = memo<{ currentId?: string }>(({ currentId }) => {
const latestChangelogId = useGlobalStore((s) => s.status.latestChangelogId);
const [latestChangelogId, updateSystemStatus] = useGlobalStore((s) => [
s.status.latestChangelogId,
s.updateSystemStatus,
]);
const router = useRouter();

useTimeout(() => {
if (latestChangelogId !== currentId) {
if (!currentId) return;
if (!latestChangelogId) {
updateSystemStatus({ latestChangelogId: currentId });
} else if (latestChangelogId !== currentId) {
router.push('/changelog/modal');
}
}, 1000);
Expand Down
2 changes: 1 addition & 1 deletion src/features/User/UserPanel/useMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const useMenu = () => {
{
icon: <Icon icon={FileClockIcon} />,
key: 'changelog',
label: <Link href={'/changelog'}>{t('changelog')}</Link>,
label: <Link href={'/changelog/modal'}>{t('changelog')}</Link>,
},
{
children: [
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/changelog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ChangelogService {
return this.mergeChangelogs(data.cloud, data.community).slice(0, 5);
} catch (e) {
console.error('Error getting changelog lists:', e);
return false as any;
return [];
}
}

Expand Down

0 comments on commit 5ad66a6

Please sign in to comment.