Skip to content

Commit

Permalink
fix: entries hasNext
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Aug 30, 2024
1 parent 3f1c588 commit 4cb5678
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
44 changes: 42 additions & 2 deletions src/hono.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,25 @@ declare const invitations: drizzle_orm_pg_core.PgTableWithColumns<{
};
dialect: "pg";
}>;
declare const invitationsOpenAPISchema: zod.ZodObject<{
code: zod.ZodString;
createdAt: zod.ZodNullable<zod.ZodString>;
fromUserId: zod.ZodString;
toUserId: zod.ZodNullable<zod.ZodString>;
}, zod.UnknownKeysParam, zod.ZodTypeAny, {
code: string;
createdAt: string | null;
fromUserId: string;
toUserId: string | null;
}, {
code: string;
createdAt: string | null;
fromUserId: string;
toUserId: string | null;
}>;
declare const invitationsRelations: drizzle_orm.Relations<"invitations", {
users: drizzle_orm.One<"user", false>;
}>;

declare const subscriptions: drizzle_orm_pg_core.PgTableWithColumns<{
name: "subscriptions";
Expand Down Expand Up @@ -2493,6 +2512,26 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
status: 200;
};
};
"/invitations": {
$get: {
input: {};
output: {
code: 0;
data: {
code: string;
createdAt: string | null;
users: {
name: string | null;
id: string;
image: string | null;
} | null;
toUserId: string | null;
}[];
};
outputFormat: "json";
status: 200;
};
};
} & {
"/wallets/transactions/tip": {
$post: {
Expand Down Expand Up @@ -3206,7 +3245,7 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
};
output: {
code: 0;
total: number;
remaining: number;
data?: {
entries: {
description: string | null;
Expand Down Expand Up @@ -3263,6 +3302,7 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
}[] | undefined;
} | undefined;
}[] | undefined;
total?: number | undefined;
};
outputFormat: "json";
status: 200;
Expand Down Expand Up @@ -3495,4 +3535,4 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
}, "/">;
type AppType = typeof _routes;

export { type ActionsModel, type AppType, type AttachmentsModel, type EntriesModel, type EntryReadHistoriesModel, type FeedModel, type MediaModel, type SettingsModel, accounts, actions, actionsItemOpenAPISchema, actionsOpenAPISchema, actionsRelations, collections, collectionsOpenAPISchema, collectionsRelations, entries, entriesOpenAPISchema, entriesRelations, entryReadHistories, entryReadHistoriesOpenAPISchema, entryReadHistoriesRelations, feedPowerTokens, feedPowerTokensOpenAPISchema, feedPowerTokensRelations, feeds, feedsInputSchema, feedsOpenAPISchema, feedsRelations, invitations, languageSchema, sessions, subscriptions, subscriptionsOpenAPISchema, subscriptionsRelations, timeline, timelineOpenAPISchema, timelineRelations, transactionType, transactions, transactionsOpenAPISchema, transactionsRelations, users, usersOpenApiSchema, usersRelations, verificationTokens, wallets, walletsOpenAPISchema, walletsRelations };
export { type ActionsModel, type AppType, type AttachmentsModel, type EntriesModel, type EntryReadHistoriesModel, type FeedModel, type MediaModel, type SettingsModel, accounts, actions, actionsItemOpenAPISchema, actionsOpenAPISchema, actionsRelations, collections, collectionsOpenAPISchema, collectionsRelations, entries, entriesOpenAPISchema, entriesRelations, entryReadHistories, entryReadHistoriesOpenAPISchema, entryReadHistoriesRelations, feedPowerTokens, feedPowerTokensOpenAPISchema, feedPowerTokensRelations, feeds, feedsInputSchema, feedsOpenAPISchema, feedsRelations, invitations, invitationsOpenAPISchema, invitationsRelations, languageSchema, sessions, subscriptions, subscriptionsOpenAPISchema, subscriptionsRelations, timeline, timelineOpenAPISchema, timelineRelations, transactionType, transactions, transactionsOpenAPISchema, transactionsRelations, users, usersOpenApiSchema, usersRelations, verificationTokens, wallets, walletsOpenAPISchema, walletsRelations };
4 changes: 2 additions & 2 deletions src/renderer/src/modules/entry-column/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export function EntryColumn() {
List: EntryListContent,
Footer: useCallback(() => {
if (!isFetchingNextPage) return null
return <EntryItemSkeleton view={view} />
return <EntryItemSkeleton view={view} count={Math.min(entries.data?.pages?.[0].data?.length || 20, entries.data?.pages.at(-1)?.remaining || 20)} />
}, [isFetchingNextPage, view]),
ScrollSeekPlaceholder: useCallback(
() => <EntryItemSkeleton view={view} single />,
() => <EntryItemSkeleton view={view} count={1} />,
[view],
),
},
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/src/modules/entry-column/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ const LoadingCircleFallback = (

export const EntryItemSkeleton: FC<{
view: FeedViewType
single?: boolean
}> = memo(({ view, single }) => {
count?: number
}> = memo(({ view, count }) => {
const SkeletonItem = SkeletonItemMap[view]
if (single) {
if (count === 1) {
return SkeletonItem
}

Expand All @@ -129,17 +129,17 @@ export const EntryItemSkeleton: FC<{
<div
className={cn(views[view].gridMode ? girdClassNames : "flex flex-col")}
>
{createSkeletonItems(SkeletonItem)}
{createSkeletonItems(SkeletonItem, count || 10)}
</div>
) :
(
LoadingCircleFallback
)
})

const createSkeletonItems = (element: ReactNode) => {
const createSkeletonItems = (element: ReactNode, count: number) => {
const children = [] as ReactNode[]
for (let i = 0; i < 10; i++) {
for (let i = 0; i < count; i++) {
children.push(element)
}
return children
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/queries/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const useEntries = ({
useAuthInfiniteQuery(entries.entries({ id, view, read }), {
enabled: id !== undefined,
getNextPageParam: (lastPage) => {
if (!lastPage.data?.length) {
if (!lastPage.data?.length || lastPage.remaining === 0) {
return null
}
return lastPage.data.at(-1)!.entries.publishedAt
Expand Down

0 comments on commit 4cb5678

Please sign in to comment.