Unverified 提交 936cc73c authored 作者: wwwillchen-bot's avatar wwwillchen-bot 提交者: GitHub

fix: prevent duplicate release notes checks using ref (#2912)

## Summary - Add `hasCheckedReleaseNotes` ref to track whether release notes have already been checked in the current session - Prevent the useEffect from running multiple times due to settings/appVersion dependency changes - Refactor conditional logic to use early-return pattern for improved readability ## Test plan - Open the app and navigate to Home page - Verify release notes dialog only shows once per session when there are new release notes - Confirm no duplicate API calls to `doesReleaseNoteExist` 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2912" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> --------- Co-authored-by: 's avatarWill Chen <willchen90@gmail.com> Co-authored-by: 's avatarclaude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
上级 d8774673
......@@ -45,6 +45,10 @@ import {
import { hasDyadProKey, getEffectiveDefaultChatMode } from "@/lib/schemas";
import { useFreeAgentQuota } from "@/hooks/useFreeAgentQuota";
// Track whether we've already checked release notes this session (module-scoped
// so it persists across component unmount/remount cycles).
let hasCheckedReleaseNotes = false;
// Adding an export for attachments
export interface HomeSubmitOptions {
attachments?: FileAttachment[];
......@@ -86,35 +90,39 @@ export default function HomePage() {
useEffect(() => {
const updateLastVersionLaunched = async () => {
if (
appVersion &&
settings &&
settings.lastShownReleaseNotesVersion !== appVersion
hasCheckedReleaseNotes ||
!appVersion ||
!settings ||
settings.lastShownReleaseNotesVersion === appVersion
) {
const shouldShowReleaseNotes = !!settings.lastShownReleaseNotesVersion;
await updateSettings({
lastShownReleaseNotesVersion: appVersion,
});
// It feels spammy to show release notes if it's
// the users very first time.
if (!shouldShowReleaseNotes) {
return;
}
return;
}
hasCheckedReleaseNotes = true;
try {
const result = await ipc.system.doesReleaseNoteExist({
version: appVersion,
});
const shouldShowReleaseNotes = !!settings.lastShownReleaseNotesVersion;
await updateSettings({
lastShownReleaseNotesVersion: appVersion,
});
// It feels spammy to show release notes if it's
// the users very first time.
if (!shouldShowReleaseNotes) {
return;
}
try {
const result = await ipc.system.doesReleaseNoteExist({
version: appVersion,
});
if (result.exists && result.url) {
setReleaseUrl(result.url + "?hideHeader=true&theme=" + theme);
setReleaseNotesOpen(true);
}
} catch (err) {
console.warn(
"Unable to check if release note exists for: " + appVersion,
err,
);
if (result.exists && result.url) {
setReleaseUrl(result.url + "?hideHeader=true&theme=" + theme);
setReleaseNotesOpen(true);
}
} catch (err) {
console.warn(
"Unable to check if release note exists for: " + appVersion,
err,
);
}
};
updateLastVersionLaunched();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论