mirror of
https://github.com/acid-info/Kurate.git
synced 2025-02-11 15:26:29 +00:00
feat: delete draft persona (#282)
This commit is contained in:
parent
da0c1f0543
commit
ffffc0e38e
@ -182,6 +182,20 @@ export class InMemoryAndIPFS implements Adapter {
|
||||
)
|
||||
}
|
||||
|
||||
deleteDraftPersona(index: number): Promise<void> {
|
||||
return new Promise((resolve) =>
|
||||
personas.update(({ draft, ...state }) => {
|
||||
const newDraft = draft.filter((_, i) => i !== index)
|
||||
|
||||
saveToLocalStorage('drafts', newDraft)
|
||||
|
||||
resolve()
|
||||
|
||||
return { ...state, draft: newDraft }
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
async publishPersona(draftPersona: DraftPersona, signer: Signer): Promise<void> {
|
||||
await signer.signMessage('This "transaction" publishes persona')
|
||||
|
||||
|
@ -18,6 +18,7 @@ export interface Adapter {
|
||||
removePersonaFromFavorite: (groupId: string, persona?: Persona) => Promise<void>
|
||||
addPersonaDraft: (draftPersona: DraftPersona) => Promise<number>
|
||||
updatePersonaDraft: (index: number, draftPersona: DraftPersona) => Promise<void>
|
||||
deleteDraftPersona: (index: number) => Promise<void>
|
||||
publishPersona(draftPersona: DraftPersona, signer: Signer): Promise<void>
|
||||
|
||||
uploadPicture(picture: string): Promise<string>
|
||||
|
@ -96,6 +96,20 @@ export class ZkitterAdapter implements Adapter {
|
||||
)
|
||||
}
|
||||
|
||||
deleteDraftPersona(index: number): Promise<void> {
|
||||
return new Promise((resolve) =>
|
||||
personas.update(({ draft, ...state }) => {
|
||||
const newDraft = draft.filter((_, i) => i !== index)
|
||||
|
||||
saveToLocalStorage('drafts', newDraft)
|
||||
|
||||
resolve()
|
||||
|
||||
return { ...state, draft: newDraft }
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
async publishPersona(draftPersona: DraftPersona, signer: Signer): Promise<void> {
|
||||
// FIXME: properly implement
|
||||
console.error('NOT IMPLEMENTED', 'publishPersona')
|
||||
|
@ -57,6 +57,7 @@
|
||||
| 'done'
|
||||
|
||||
let showWarningDiscardModal = false
|
||||
let showWarningDeletePersona = false
|
||||
|
||||
const setState = (newState: State) => {
|
||||
state = newState
|
||||
@ -119,6 +120,33 @@
|
||||
</svelte:fragment>
|
||||
</InfoBox>
|
||||
</InfoScreen>
|
||||
{:else if showWarningDeletePersona}
|
||||
<InfoScreen title="Delete persona">
|
||||
<InfoBox>
|
||||
<div class="icon">
|
||||
<Info size={32} />
|
||||
</div>
|
||||
<h2>Are you sure you want to delete this draft persona?</h2>
|
||||
<LearnMore href="/" />
|
||||
<svelte:fragment slot="buttons">
|
||||
<Button
|
||||
icon={Checkmark}
|
||||
variant="primary"
|
||||
label="Yes, delete persona"
|
||||
on:click={() => {
|
||||
adapter.deleteDraftPersona(personaIndex)
|
||||
goto(ROUTES.HOME)
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
variant="secondary"
|
||||
label="No, keep it"
|
||||
icon={Undo}
|
||||
on:click={() => (showWarningDeletePersona = false)}
|
||||
/>
|
||||
</svelte:fragment>
|
||||
</InfoBox>
|
||||
</InfoScreen>
|
||||
{:else if postToDelete !== undefined}
|
||||
<InfoScreen title="Delete seed post">
|
||||
<InfoBox>
|
||||
@ -201,19 +229,25 @@
|
||||
/>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
<Button
|
||||
slot="button_other"
|
||||
variant="secondary"
|
||||
label="Edit Persona details"
|
||||
icon={EditPersona}
|
||||
on:click={() => {
|
||||
name = persona.name
|
||||
pitch = persona.pitch
|
||||
description = persona.description
|
||||
minReputation = persona.minReputation
|
||||
setState('edit_text')
|
||||
}}
|
||||
/>
|
||||
<svelte:fragment slot="button_other">
|
||||
<Button
|
||||
variant="secondary"
|
||||
label="Edit Persona details"
|
||||
icon={EditPersona}
|
||||
on:click={() => {
|
||||
name = persona.name
|
||||
pitch = persona.pitch
|
||||
description = persona.description
|
||||
minReputation = persona.minReputation
|
||||
setState('edit_text')
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
variant="secondary"
|
||||
icon={TrashCan}
|
||||
on:click={() => (showWarningDeletePersona = true)}
|
||||
/>
|
||||
</svelte:fragment>
|
||||
<Divider />
|
||||
<Container>
|
||||
<InfoBox>
|
||||
|
Loading…
x
Reference in New Issue
Block a user