edit-access+redirect
This commit is contained in:
parent
9b7079def5
commit
f8bf3d86a0
|
@ -51,7 +51,10 @@ const DialogAvatar = (props: Props) => {
|
|||
<Show when={Boolean(props.url)} fallback={<div class={styles.letter}>{nameFirstLetter()}</div>}>
|
||||
<div
|
||||
class={styles.imageHolder}
|
||||
style={{ 'background-image': `url(${getImageUrl(props.url, { width: 40, height: 40 })})` }}
|
||||
style={{ 'background-image': `url(
|
||||
${props.url.includes('discours.io') ? getImageUrl(props.url, { width: 40, height: 40 }) : props.url }
|
||||
)`
|
||||
}}
|
||||
/>
|
||||
</Show>
|
||||
</div>
|
||||
|
|
|
@ -210,6 +210,13 @@ export const apiClient = {
|
|||
return resp.data.get_shout
|
||||
},
|
||||
|
||||
getMyShout: async (shout_id: number) => {
|
||||
const resp = await apiClient.private.query(shoutLoad, { shout_id }).toPromise()
|
||||
if (resp.error) console.error(resp)
|
||||
|
||||
return resp.data.get_shout
|
||||
},
|
||||
|
||||
getShouts: async (options: LoadShoutsOptions) => {
|
||||
const resp = await publicGraphQLClient.query(shoutsLoadBy, { options }).toPromise()
|
||||
if (resp.error) console.error(resp)
|
||||
|
|
|
@ -7,8 +7,10 @@ import { useLocalize } from '../context/localize'
|
|||
import { apiClient } from '../graphql/client/core'
|
||||
import { Shout } from '../graphql/schema/core.gen'
|
||||
import { useRouter } from '../stores/router'
|
||||
import { router } from '../stores/router'
|
||||
|
||||
import { LayoutType } from './types'
|
||||
import { redirectPage } from "@nanostores/router";
|
||||
|
||||
const EditView = lazy(() => import('../components/Views/EditView/EditView'))
|
||||
|
||||
|
@ -21,8 +23,14 @@ export const EditPage = () => {
|
|||
const [shout, setShout] = createSignal<Shout>(null)
|
||||
|
||||
onMount(async () => {
|
||||
const loadedShout = await apiClient.getShoutById(shoutId())
|
||||
setShout(loadedShout)
|
||||
const loadedShout = await apiClient.getMyShout(shoutId())
|
||||
console.log(loadedShout)
|
||||
if (loadedShout) {
|
||||
setShout(loadedShout)
|
||||
}
|
||||
else {
|
||||
redirectPage(router, 'drafts')
|
||||
}
|
||||
})
|
||||
|
||||
const title = createMemo(() => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user