fix: creating post behavior and copy (#343)

This commit is contained in:
Vojtech Simetka 2023-04-02 21:19:00 +02:00 committed by GitHub
parent 24d56a02de
commit 30b6cef3d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 9 deletions

View File

@ -281,7 +281,7 @@ export class Firebase implements Adapter {
text: string, text: string,
images: string[], images: string[],
signer: Signer, signer: Signer,
): Promise<void> { ): Promise<string> {
const address = await signer.getAddress() const address = await signer.getAddress()
const isMemberOfGroup = get(personas).all.get(groupId)?.participants?.includes(address) const isMemberOfGroup = get(personas).all.get(groupId)?.participants?.includes(address)
@ -304,7 +304,7 @@ export class Firebase implements Adapter {
// Store post to pending // Store post to pending
const pendingPosts = collection(db, `personas/${groupId}/pending`) const pendingPosts = collection(db, `personas/${groupId}/pending`)
addDoc(pendingPosts, post) const postDoc = await addDoc(pendingPosts, post)
const profileCollection = collection(db, `users/${address}/transactions`) const profileCollection = collection(db, `users/${address}/transactions`)
await addDoc(profileCollection, { await addDoc(profileCollection, {
@ -322,6 +322,8 @@ export class Firebase implements Adapter {
{ address, go: go - NEW_POST_GO_PRICE, repTotal, repStaked: repStaked + NEW_POST_REP_PRICE }, { address, go: go - NEW_POST_GO_PRICE, repTotal, repStaked: repStaked + NEW_POST_REP_PRICE },
{ merge: true }, { merge: true },
) )
return postDoc.id
} }
async subscribePersonaPosts(groupId: string): Promise<() => unknown> { async subscribePersonaPosts(groupId: string): Promise<() => unknown> {

View File

@ -404,7 +404,7 @@ export class InMemoryAndIPFS implements Adapter {
text: string, text: string,
images: string[], images: string[],
signer: Signer, signer: Signer,
): Promise<void> { ): Promise<string> {
await signer.signMessage('This "transaction" publishes a post to pending') await signer.signMessage('This "transaction" publishes a post to pending')
const post = { const post = {
@ -430,6 +430,8 @@ export class InMemoryAndIPFS implements Adapter {
}) })
return { transactions } return { transactions }
}) })
return post.postId
} }
async subscribePersonaPosts(groupId: string): Promise<() => unknown> { async subscribePersonaPosts(groupId: string): Promise<() => unknown> {

View File

@ -26,7 +26,7 @@ export interface Adapter {
uploadPicture(picture: string): Promise<string> uploadPicture(picture: string): Promise<string>
getPicture(cid: string): string getPicture(cid: string): string
publishPost(groupId: string, text: string, images: string[], signer: Signer): Promise<void> publishPost(groupId: string, text: string, images: string[], signer: Signer): Promise<string>
subscribePersonaPosts(groupId: string): Promise<() => unknown> subscribePersonaPosts(groupId: string): Promise<() => unknown>
voteOnPost(groupId: string, postId: string, vote: '+' | '-', signer: Signer): Promise<void> voteOnPost(groupId: string, postId: string, vote: '+' | '-', signer: Signer): Promise<void>

View File

@ -332,7 +332,7 @@ export class ZkitterAdapter implements Adapter {
text: string, text: string,
images: string[], images: string[],
signer: Signer, signer: Signer,
): Promise<void> { ): Promise<string> {
// FIXME: properly implement // FIXME: properly implement
console.error('NOT IMPLEMENTED', 'publishPost', signer) console.error('NOT IMPLEMENTED', 'publishPost', signer)
@ -344,6 +344,8 @@ export class ZkitterAdapter implements Adapter {
} }
posts.addPending(post, groupId) posts.addPending(post, groupId)
return post.postId
} }
async subscribePersonaPosts(groupId: string): Promise<() => unknown> { async subscribePersonaPosts(groupId: string): Promise<() => unknown> {

View File

@ -153,7 +153,7 @@
<Banner icon={Info} variant="danger">No GO left in this cycle</Banner> <Banner icon={Info} variant="danger">No GO left in this cycle</Banner>
{/if} {/if}
<div class={`header ${y > 0 ? 'scrolled' : ''}`}> <div class={`header ${y > 0 ? 'scrolled' : ''}`}>
<Header title={`Pending • ${persona.name}`} onBack={() => history.back()}> <Header title={`Pending • ${persona.name}`} onBack={() => goto(ROUTES.PERSONA(groupId))}>
{#if $profile.signer !== undefined} {#if $profile.signer !== undefined}
<Button variant="primary" icon={Edit} on:click={() => goto(ROUTES.POST_NEW(groupId))} /> <Button variant="primary" icon={Edit} on:click={() => goto(ROUTES.POST_NEW(groupId))} />
{:else} {:else}

View File

@ -16,6 +16,8 @@
import { page } from '$app/stores' import { page } from '$app/stores'
import { personas } from '$lib/stores/persona' import { personas } from '$lib/stores/persona'
import { NEW_POST_GO_PRICE, NEW_POST_REP_PRICE } from '$lib/constants' import { NEW_POST_GO_PRICE, NEW_POST_REP_PRICE } from '$lib/constants'
import { ROUTES } from '$lib/routes'
import { goto } from '$app/navigation'
const persona = $personas.all.get($page.params.id) const persona = $personas.all.get($page.params.id)
@ -166,15 +168,20 @@
</div> </div>
<h2>Your post is now pending review</h2> <h2>Your post is now pending review</h2>
<p> <p>
Your post has been added to "Persona name's" pending list for community review. If it gets Your post has been added to "{persona.name}'s" pending list for community review. If it gets
promoted it will be automatically published to "Persona name's" page when the new epoch promoted it will be automatically published to "{persona.name}'s" page when the new epoch
begins. begins.
</p> </p>
<LearnMore href="/" /> <LearnMore href="/" />
</div> </div>
<svelte:fragment slot="buttons"> <svelte:fragment slot="buttons">
<Button icon={Checkmark} variant="primary" label="Done" on:click={() => history.back()} /> <Button
icon={Checkmark}
variant="primary"
label="Done"
on:click={() => goto(ROUTES.PERSONA_PENDING(persona.personaId))}
/>
</svelte:fragment> </svelte:fragment>
</InfoScreen> </InfoScreen>
{/if} {/if}