Skip to content

Commit eab9ba1

Browse files
Sora4431claude
andcommitted
fix(share): address Copilot review comments
- Add ssr=false to avoid localStorage access during SSR (isOwner always false) - Return isLoggedIn from load; readOnly only when logged in && not owner - Pass all handlers unconditionally; readOnly prop handles UI suppression - Fix setTimeout race condition in copyPublicLink with clearTimeout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 27abcf4 commit eab9ba1

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

apps/web/src/routes/[id]/+page.svelte

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,14 @@
184184

185185
{#key data.itinerary.theme_id}
186186
<!-- readOnly は standard-seasons テーマのみ対応。他テーマは issue #159 で対応予定 -->
187+
<!-- ログイン済み && 非オーナーのみ readOnly。未ログインは既存動作を維持 -->
187188
<ItineraryView
188189
{itinerary}
189190
{steps}
190-
readOnly={!data.isOwner}
191-
onUpdateItinerary={!data.isOwner ? undefined : handleUpdateItinerary}
192-
onCreateStep={!data.isOwner ? undefined : handleCreateStep}
193-
onUpdateStep={!data.isOwner ? undefined : handleUpdateStep}
194-
onDeleteStep={!data.isOwner ? undefined : handleDeleteStep}
191+
readOnly={data.isLoggedIn && !data.isOwner}
192+
onUpdateItinerary={handleUpdateItinerary}
193+
onCreateStep={handleCreateStep}
194+
onUpdateStep={handleUpdateStep}
195+
onDeleteStep={handleDeleteStep}
195196
/>
196197
{/key}

apps/web/src/routes/[id]/+page.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@ import { loadTheme } from '$lib/themes';
77
import { error } from '@sveltejs/kit';
88

99
export const prerender = false;
10+
// userAuth は localStorage 依存のため SSR では動作しない → CSR のみで実行
11+
export const ssr = false;
1012

1113
export const load: PageLoad = async ({ params }) => {
1214
try {
1315
const itinerary = await itineraryApi.get(params.id);
1416
const theme = await loadTheme(itinerary.theme_id);
1517
const steps = await stepApi.list(params.id);
1618

19+
const isLoggedIn = userAuth.isLoggedIn();
1720
let isOwner = false;
18-
if (userAuth.isLoggedIn()) {
21+
if (isLoggedIn) {
1922
try {
2023
await userApi.checkOwnership(params.id);
2124
isOwner = true;
22-
} catch (e) {
25+
} catch {
2326
// 404 = bookmark not found (not owner)
2427
// 401 = token expired → isLoggedIn() で事前にチェック済みのため通常発生しない
2528
isOwner = false;
@@ -30,6 +33,7 @@ export const load: PageLoad = async ({ params }) => {
3033
itinerary,
3134
theme,
3235
steps,
36+
isLoggedIn,
3337
isOwner,
3438
};
3539
} catch (e) {

apps/web/src/routes/profile/+page.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
let formError = $state<string | null>(null);
2020
let submitting = $state(false);
2121
let copiedId = $state<string | null>(null);
22+
let copyTimeout: ReturnType<typeof setTimeout> | null = null;
2223
2324
onMount(async () => {
2425
loggedIn = userAuth.isLoggedIn();
@@ -81,7 +82,8 @@
8182
const url = window.location.origin + '/' + itineraryId;
8283
await navigator.clipboard.writeText(url);
8384
copiedId = itineraryId;
84-
setTimeout(() => { copiedId = null; }, 2000);
85+
if (copyTimeout) clearTimeout(copyTimeout);
86+
copyTimeout = setTimeout(() => { copiedId = null; }, 2000);
8587
} catch {
8688
alert('クリップボードへのコピーに失敗しました');
8789
}

0 commit comments

Comments
 (0)