Skip to content

Commit

Permalink
feat: disable publishing several personas
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechsimetka committed May 4, 2023
1 parent d11e9c7 commit 149cdb5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/ui/src/routes/persona/draft/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
let postToEditImages: string[] = []
let postToDelete: DraftPost | undefined = undefined
let publishedPersonaId: string | undefined = undefined
let publishing = false
type State = 'persona_preview' | 'edit_text' | 'edit_rep' | 'post_new' | 'publish_warning'
Expand All @@ -75,10 +76,16 @@
}
async function publishPersona() {
if (!$profile.signer) return
try {
publishing = true
if (!$profile.signer) throw new Error('No signer, please login')
publishedPersonaId = await adapter.publishPersona(persona, $profile.signer)
adapter.addPersonaToFavorite(publishedPersonaId)
publishedPersonaId = await adapter.publishPersona(persona, $profile.signer)
adapter.addPersonaToFavorite(publishedPersonaId)
} catch (e) {
console.error(e)
}
publishing = false
}
let y: number
Expand Down Expand Up @@ -397,11 +404,12 @@

<svelte:fragment slot="buttons">
{#if $tokens.go >= TOKEN_POST_COST}
<Button icon={Checkmark} variant="primary" label="I agree" on:click={publishPersona} />
<Button icon={Checkmark} variant="primary" disabled={publishing} label={publishing ? "Publishing..." : "I agree"} on:click={publishPersona} />
<Button
variant="secondary"
label="Nope"
icon={Close}
disabled={publishing}
on:click={() => setState('persona_preview')}
/>
{:else}
Expand Down

0 comments on commit 149cdb5

Please sign in to comment.