Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/routes/(app)/favorites/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,27 @@
let reelContainer: HTMLDivElement | null = $state(null);
let showViewers = $state(false);

// History management — push a state entry when the reel opens so the
// Android back gesture (and browser back button) closes it instead of
// navigating away from the favorites page entirely.
// Push a history entry when reel opens so back gesture closes it, not navigates away.
let reelClosedViaBack = false;
let reelDismissed = false;

function onReelPopState() {
reelClosedViaBack = true;
closeReel();
// Defer so page.state is updated before we inspect it. If favReel is still
// set, a sheet on top closed — don't dismiss the reel. If gone, close it.
setTimeout(() => {
if (page.state.favReel || viewMode !== 'reel') return;
reelClosedViaBack = true;
closeReel();
}, 0);
}

// Close viewers sheet when scrolling to a different clip
$effect(() => {
// eslint-disable-next-line sonarjs/void-use -- read activeIndex to re-run on scroll
void activeIndex;
showViewers = false;
});

const currentUserId = $derived(page.data.user?.id ?? '');
const autoScroll = $derived(page.data.user?.autoScroll ?? false);
const gifEnabled = $derived(!!page.data.gifEnabled);
const renderWindow = 2;

Expand Down Expand Up @@ -138,7 +139,6 @@
if (slot) slot.scrollIntoView({ behavior: 'smooth' });
}

// IntersectionObserver to track active clip in reel mode
$effect(() => {
if (viewMode !== 'reel' || !reelContainer) return;
// eslint-disable-next-line sonarjs/void-use -- re-run when clips change
Expand Down Expand Up @@ -234,7 +234,7 @@
{currentUserId}
active={i === activeIndex}
index={i}
{autoScroll}
autoScroll={false}
{gifEnabled}
canEditCaption={clip.addedBy === currentUserId}
seenByOthers={clip.seenByOthers}
Expand Down
40 changes: 22 additions & 18 deletions src/routes/share/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import ExportIcon from 'phosphor-svelte/lib/ExportIcon';

const shareUrl = $derived($page.data.shareUrl as string);
const fromShortcut = $derived($page.data.fromShortcut as boolean);
const platform = $derived(platformLabel(shareUrl));
const isValid = $derived(isSupportedUrl(shareUrl));
const detectedPlatform = $derived(shareUrl ? detectPlatform(shareUrl) : null);
Expand All @@ -36,6 +35,14 @@
let success = $state(false);
let clipId = $state('');
let contentType = $state('');
let autoSubmitted = $state(false);

$effect(() => {
if (isValid && platformAllowed && !autoSubmitted) {
autoSubmitted = true;
handleSubmit();
}
});

async function handleSubmit() {
error = '';
Expand Down Expand Up @@ -105,30 +112,26 @@
<h1 class="share-title">Added!</h1>
<p class="share-desc">Your clip is downloading.</p>
<button class="btn-primary" onclick={openFeed}>Open Scrolly</button>
{:else}
{:else if loading}
<div class="icon-wrap">
<ExportIcon size={28} />
</div>
{#if fromShortcut}
<h1 class="share-title">Couldn't add automatically</h1>
<p class="share-desc">
The shortcut wasn't able to add this clip. Tap below to add it manually.
</p>
{:else}
<h1 class="share-title">Add to feed</h1>
{/if}
<h1 class="share-title">Adding to feed…</h1>
{#if platform}
<span class="platform-pill">{platform}</span>
{/if}
<p class="share-url">{shareUrl}</p>

{#if error}
<p class="share-error">{error}</p>
{:else if error}
<div class="icon-wrap err">
<XCircleIcon size={28} />
</div>
<h1 class="share-title">Couldn't add clip</h1>
<p class="share-error">{error}</p>
{#if platform}
<span class="platform-pill">{platform}</span>
{/if}

<button class="btn-primary" onclick={handleSubmit} disabled={loading}>
{loading ? 'Adding...' : 'Add to feed'}
</button>
<p class="share-url">{shareUrl}</p>
<button class="btn-primary" onclick={handleSubmit} disabled={loading}>Try again</button>
<a href={resolve('/')} class="btn-ghost">Cancel</a>
{/if}
</div>
Expand Down Expand Up @@ -175,7 +178,8 @@
animation: pop 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.icon-wrap.error {
.icon-wrap.error,
.icon-wrap.err {
background: color-mix(in srgb, var(--error) 12%, transparent);
color: var(--error);
}
Expand Down
Loading