Skip to content

Commit

Permalink
fix: click area and unread count store bug (#50)
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei authored Jun 11, 2024
1 parent d391f32 commit 937e246
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 70 deletions.
8 changes: 6 additions & 2 deletions src/renderer/src/components/feed-column/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ActionButton } from "@renderer/components/ui/button"
import { UserButton } from "@renderer/components/user-button"
import { APP_NAME, levels, views } from "@renderer/lib/constants"
import { stopPropagation } from "@renderer/lib/dom"
import { clamp, cn } from "@renderer/lib/utils"
import { feedActions } from "@renderer/store"
import { useWheel } from "@use-gesture/react"
Expand Down Expand Up @@ -89,7 +90,7 @@ export function FeedColumn() {
{APP_NAME}
</div>
)}
<div className="flex items-center gap-2">
<div className="flex items-center gap-2" onClick={stopPropagation}>
<Link to="/profile">
<ActionButton tooltip="Profile">
<UserButton className="h-5 p-0" hideName />
Expand All @@ -102,7 +103,10 @@ export function FeedColumn() {
</Link>
</div>
</div>
<div className="flex w-full justify-between px-3 text-xl text-theme-vibrancyFg">
<div
className="flex w-full justify-between px-3 text-xl text-theme-vibrancyFg"
onClick={stopPropagation}
>
{views.map((item, index) => (
<ActionButton
key={item.name}
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/components/feed-column/list.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useBizQuery } from "@renderer/hooks/useBizQuery"
import { levels, views } from "@renderer/lib/constants"
import { stopPropagation } from "@renderer/lib/dom"
import type { FeedViewType } from "@renderer/lib/enum"
import { cn } from "@renderer/lib/utils"
import type { FeedListModel, SubscriptionResponse } from "@renderer/models"
Expand Down Expand Up @@ -115,6 +116,7 @@ export function FeedList({
<div className={cn(className, "font-medium")}>
{!hideTitle && (
<div
onClick={stopPropagation}
className={cn("mb-2 flex items-center justify-between px-2.5 py-1")}
>
<div
Expand Down
132 changes: 66 additions & 66 deletions src/renderer/src/hono.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
};
};
output: {
code: 0;
data: Record<string, number>;
code: 0;
};
outputFormat: "json";
status: 200;
Expand Down Expand Up @@ -67,8 +67,8 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
};
};
output: {
code: 0;
data: boolean;
code: 0;
};
outputFormat: "json";
status: 200;
Expand Down Expand Up @@ -149,16 +149,15 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
};
};
output: {
code: 0;
data: {
feed: {
url: string;
checkedAt: string;
nextCheckAt: string;
description?: string | null | undefined;
title?: string | null | undefined;
id?: string | undefined;
image?: string | null | undefined;
title?: string | null | undefined;
description?: string | null | undefined;
siteUrl?: string | null | undefined;
lastModifiedHeader?: string | null | undefined;
etagHeader?: string | null | undefined;
Expand All @@ -169,14 +168,15 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
subscriptionCount: number;
readCount: number;
subscription?: {
title: string | null;
userId: string;
feedId: string;
title: string | null;
view: number;
category: string | null;
isPrivate: boolean | null;
} | undefined;
};
code: 0;
};
outputFormat: "json";
status: 200;
Expand Down Expand Up @@ -208,11 +208,11 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
output: {
data: {
feed: {
description: string | null;
title: string | null;
id: string;
image: string | null;
url: string;
title: string | null;
description: string | null;
siteUrl: string | null;
checkedAt: string;
nextCheckAt: string;
Expand All @@ -223,12 +223,12 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
errorAt: string | null;
};
entries?: {
description: string | null;
title: string | null;
content: string | null;
id: string;
feedId: string;
url: string | null;
title: string | null;
description: string | null;
content: string | null;
guid: string;
author: string | null;
authorUrl: string | null;
Expand All @@ -239,9 +239,9 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
categories: string[] | null;
enclosures?: {
url: string;
length?: number | undefined;
type?: string | undefined;
title?: string | undefined;
type?: string | undefined;
length?: number | undefined;
}[] | null | undefined;
}[] | undefined;
docs?: string | undefined;
Expand All @@ -258,12 +258,12 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
$post: {
input: {};
output: {
code: 0;
data: {
userId: string;
sessionToken: string;
expires: string;
};
code: 0;
};
outputFormat: "json";
status: 200;
Expand Down Expand Up @@ -312,11 +312,26 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
code: 0;
total: number;
data?: {
entries: {
description: string | null;
feeds: {
id: string;
image: string | null;
url: string;
title: string | null;
description: string | null;
siteUrl: string | null;
checkedAt: string;
nextCheckAt: string;
lastModifiedHeader: string | null;
etagHeader: string | null;
ttl: number | null;
errorMessage: string | null;
errorAt: string | null;
};
entries: {
id: string;
url: string | null;
title: string | null;
description: string | null;
guid: string;
author: string | null;
authorUrl: string | null;
Expand All @@ -327,26 +342,11 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
categories: string[] | null;
enclosures?: {
url: string;
length?: number | undefined;
type?: string | undefined;
title?: string | undefined;
type?: string | undefined;
length?: number | undefined;
}[] | null | undefined;
};
feeds: {
description: string | null;
title: string | null;
id: string;
image: string | null;
url: string;
siteUrl: string | null;
checkedAt: string;
nextCheckAt: string;
lastModifiedHeader: string | null;
etagHeader: string | null;
ttl: number | null;
errorMessage: string | null;
errorAt: string | null;
};
read: boolean | null;
collections?: {
createdAt: string;
Expand All @@ -365,36 +365,15 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
output: {
code: 0;
data?: {
entries: {
description: string | null;
title: string | null;
content: string | null;
id: string;
url: string | null;
guid: string;
author: string | null;
authorUrl: string | null;
authorAvatar: string | null;
changedAt: string;
publishedAt: string;
images: string[] | null;
categories: string[] | null;
enclosures?: {
url: string;
length?: number | undefined;
type?: string | undefined;
title?: string | undefined;
}[] | null | undefined;
};
collections: {
createdAt: string;
};
feeds: {
description: string | null;
title: string | null;
id: string;
image: string | null;
url: string;
title: string | null;
description: string | null;
siteUrl: string | null;
checkedAt: string;
nextCheckAt: string;
Expand All @@ -404,6 +383,27 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
errorMessage: string | null;
errorAt: string | null;
};
entries: {
id: string;
url: string | null;
title: string | null;
description: string | null;
content: string | null;
guid: string;
author: string | null;
authorUrl: string | null;
authorAvatar: string | null;
changedAt: string;
publishedAt: string;
images: string[] | null;
categories: string[] | null;
enclosures?: {
url: string;
title?: string | undefined;
type?: string | undefined;
length?: number | undefined;
}[] | null | undefined;
};
read: boolean | null;
} | undefined;
};
Expand All @@ -419,14 +419,13 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
};
};
output: {
code: 0;
data: {
description: string | null;
title: string | null;
content: string | null;
id: string;
feedId: string;
url: string | null;
title: string | null;
description: string | null;
content: string | null;
guid: string;
author: string | null;
authorUrl: string | null;
Expand All @@ -437,11 +436,12 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
categories: string[] | null;
enclosures?: {
url: string;
length?: number | undefined;
type?: string | undefined;
title?: string | undefined;
type?: string | undefined;
length?: number | undefined;
}[] | null | undefined;
}[];
code: 0;
};
outputFormat: "json";
status: 200;
Expand All @@ -456,17 +456,15 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
};
};
output: {
code: 0;
data: {
title: string | null;
userId: string;
feedId: string;
feeds: {
description: string | null;
title: string | null;
id: string;
image: string | null;
url: string;
title: string | null;
description: string | null;
siteUrl: string | null;
checkedAt: string;
nextCheckAt: string;
Expand All @@ -476,10 +474,12 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
errorMessage: string | null;
errorAt: string | null;
};
title: string | null;
view: number;
category: string | null;
isPrivate: boolean | null;
}[];
code: 0;
};
outputFormat: "json";
status: 200;
Expand Down
7 changes: 5 additions & 2 deletions src/renderer/src/store/unread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const useUnreadStore = createZustandStore<UnreadState & UnreadActions>(
})

const { data } = unread
get().internal_reset()
set((state) =>
produce(state, (state) => {
get().internal_reset()
for (const feedId in data) {
state.data[feedId] = data[feedId]
return state
Expand All @@ -48,7 +48,10 @@ export const useUnreadStore = createZustandStore<UnreadState & UnreadActions>(
set((state) =>
produce(state, (state) => {
const cur = state.data[feedId]
if (cur === undefined) return state
if (cur === undefined) {
state.data[feedId] = inc
return state
}
state.data[feedId] = (cur || 0) + inc
return state
}),
Expand Down

0 comments on commit 937e246

Please sign in to comment.