Allow dismissing zap prompt

This commit is contained in:
Jon Staab 2024-06-21 10:25:50 -07:00
parent 2a32f31aba
commit 2e3df2838d
3 changed files with 18 additions and 13 deletions

View File

@ -1,6 +1,7 @@
<script lang="ts">
import {onMount} from "svelte"
import {writable, hash} from "@welshman/lib"
import {seconds} from "hurdak"
import {writable, now, hash} from "@welshman/lib"
import {createScroller, synced} from "src/util/misc"
import {fly, fade} from "src/util/transition"
import Anchor from "src/partials/Anchor.svelte"
@ -28,6 +29,8 @@
const splits = [["zap", $env.PLATFORM_PUBKEY, "", "1"]]
const promptDismissed = synced("feed/promptDismissed", 0)
const shouldHideReplies = showControls ? synced("Feed.shouldHideReplies", false) : writable(false)
const reload = async () => {
@ -103,12 +106,19 @@
{anchor}
{note} />
</div>
{#if i > 20 && parseInt(hash(note.id)) % 100 === 0}
<Card class="flex items-center justify-between">
{#if i > 20 && parseInt(hash(note.id)) % 100 === 0 && $promptDismissed < now() - seconds(7, "day")}
<Card class="group flex items-center justify-between">
<p class="text-xl">Enjoying Coracle?</p>
<Anchor modal button accent href={router.at("zap").qp({splits}).toString()}>
Zap the developer
</Anchor>
<div class="flex gap-2">
<Anchor
class="text-neutral-400 opacity-0 transition-all group-hover:opacity-100"
on:click={() => promptDismissed.set(now())}>
Dismiss
</Anchor>
<Anchor modal button accent href={router.at("zap").qp({splits}).toString()}>
Zap the developer
</Anchor>
</div>
</Card>
{/if}
{/each}

View File

@ -82,7 +82,7 @@
{#if muted}
<p class="mb-1 py-24 text-center text-neutral-600">
You have hidden this note.
<Anchor class="underline" on:click={unmute}>Show</Anchor>
<Anchor class="underline" stopPropagation on:click={unmute}>Show</Anchor>
</p>
{:else}
{#if !isGroup}

View File

@ -690,9 +690,7 @@ export const updateSingleton = async (kind: number, modifyTags: ModifyTags) => {
// If we don't have a recent version loaded, re-fetch to avoid dropping updates
if ((event?.created_at || 0) < now() - seconds(5, "minute")) {
console.log("loading")
const loadedEvent = await loadOne({relays: hints.User().getUrls(), filters})
console.log("loaded", loadedEvent)
if ((loadedEvent?.created_at || 0) > (event?.created_at || 0)) {
event = loadedEvent
@ -714,15 +712,12 @@ export const updateSingleton = async (kind: number, modifyTags: ModifyTags) => {
} else {
const singleton = makeSingleton({kind})
const publicTags = modifyTags(singleton.publicTags)
encryptable = createSingleton({...singleton, publicTags})
}
console.log(1)
const template = await encryptable.reconcile(encrypt)
console.log(2, template)
await createAndPublish({...template, content, relays})
}