fix-message-struct

This commit is contained in:
Untone 2023-11-17 12:00:00 +03:00
parent 13e126589d
commit 332193622d
9 changed files with 13 additions and 15 deletions

View File

@ -19,8 +19,8 @@ type Props = {
export const Message = (props: Props) => { export const Message = (props: Props) => {
const { formatTime } = useLocalize() const { formatTime } = useLocalize()
const isOwn = props.ownId === Number(props.content.author) const isOwn = props.ownId === Number(props.content.created_by)
const user = props.members?.find((m) => m.id === Number(props.content.author)) const user = props.members?.find((m) => m.id === Number(props.content.created_by))
const [isPopupVisible, setIsPopupVisible] = createSignal<boolean>(false) const [isPopupVisible, setIsPopupVisible] = createSignal<boolean>(false)
return ( return (
@ -48,7 +48,7 @@ export const Message = (props: Props) => {
<div innerHTML={props.content.body} /> <div innerHTML={props.content.body} />
</div> </div>
</div> </div>
<div class={styles.time}>{formatTime(new Date(props.content.createdAt * 1000))}</div> <div class={styles.time}>{formatTime(new Date(props.content.created_at * 1000))}</div>
</div> </div>
) )
} }

View File

@ -37,7 +37,7 @@ export const Expo = (props: Props) => {
offset: sortedArticles().length offset: sortedArticles().length
} }
options.filters = getLayout() ? { layout: getLayout() } : { excludeLayout: 'article' } options.filters = getLayout() ? { layout: getLayout() } : { exclude_layout: 'article' }
const { hasMore } = await loadShouts(options) const { hasMore } = await loadShouts(options)
setIsLoadMoreButtonVisible(hasMore) setIsLoadMoreButtonVisible(hasMore)

View File

@ -70,7 +70,7 @@ export const InboxProvider = (props: { children: JSX.Element }) => {
try { try {
const message = await inboxClient.createMessage(args) const message = await inboxClient.createMessage(args)
setMessages((prev) => [...prev, message]) setMessages((prev) => [...prev, message])
const currentChat = chats().find((chat) => chat.id === args.chat) const currentChat = chats().find((chat) => chat.id === args.chat_id)
setChats((prev) => [ setChats((prev) => [
...prev.filter((c) => c.id !== currentChat.id), ...prev.filter((c) => c.id !== currentChat.id),
{ ...currentChat, updatedAt: message.createdAt } { ...currentChat, updatedAt: message.createdAt }

View File

@ -104,11 +104,10 @@ export const NotificationsProvider = (props: { children: JSX.Element }) => {
}, },
onmessage(event) { onmessage(event) {
const m: SSEMessage = JSON.parse(event.data) const m: SSEMessage = JSON.parse(event.data)
if (m.entity === 'chat' || m.entity == 'message') {
console.log('[context.notifications] Received message:', m) console.log('[context.notifications] Received message:', m)
if (m.entity === 'chat' || m.entity == 'message') {
messageHandler()(m) messageHandler()(m)
} else { } else {
console.log('[context.notifications] Received notification:', m)
storeNotification({ storeNotification({
...m, ...m,
id: event.id, id: event.id,

View File

@ -7,7 +7,7 @@ export default gql`
message { message {
id id
body body
author created_by
created_at created_at
reply_to reply_to
updated_at updated_at

View File

@ -8,7 +8,7 @@ export default gql`
message { message {
id id
body body
author created_by
created_at created_at
reply_to reply_to
updated_at updated_at

View File

@ -6,7 +6,7 @@ export default gql`
error error
messages { messages {
id id
author created_by
body body
reply_to reply_to
created_at created_at

View File

@ -128,7 +128,7 @@ export type LoadShoutsFilters = {
author?: InputMaybe<Scalars['String']['input']> author?: InputMaybe<Scalars['String']['input']>
body?: InputMaybe<Scalars['String']['input']> body?: InputMaybe<Scalars['String']['input']>
days?: InputMaybe<Scalars['Int']['input']> days?: InputMaybe<Scalars['Int']['input']>
excludeLayout?: InputMaybe<Scalars['String']['input']> exclude_layout?: InputMaybe<Scalars['String']['input']>
layout?: InputMaybe<Scalars['String']['input']> layout?: InputMaybe<Scalars['String']['input']>
reacted?: InputMaybe<Scalars['Boolean']['input']> reacted?: InputMaybe<Scalars['Boolean']['input']>
title?: InputMaybe<Scalars['String']['input']> title?: InputMaybe<Scalars['String']['input']>
@ -146,7 +146,7 @@ export type LoadShoutsOptions = {
} }
export type Message = { export type Message = {
author: Scalars['Int']['output'] created_by: Scalars['Int']['output']
body: Scalars['String']['output'] body: Scalars['String']['output']
chat_id: Scalars['String']['output'] chat_id: Scalars['String']['output']
created_at: Scalars['Int']['output'] created_at: Scalars['Int']['output']
@ -163,7 +163,7 @@ export enum MessageStatus {
} }
export type MessagesBy = { export type MessagesBy = {
author?: InputMaybe<Scalars['String']['input']> created_by?: InputMaybe<Scalars['String']['input']>
body?: InputMaybe<Scalars['String']['input']> body?: InputMaybe<Scalars['String']['input']>
chat?: InputMaybe<Scalars['String']['input']> chat?: InputMaybe<Scalars['String']['input']>
days?: InputMaybe<Scalars['Int']['input']> days?: InputMaybe<Scalars['Int']['input']>
@ -635,7 +635,6 @@ export type ShoutInput = {
description?: InputMaybe<Scalars['String']['input']> description?: InputMaybe<Scalars['String']['input']>
layout?: InputMaybe<Scalars['String']['input']> layout?: InputMaybe<Scalars['String']['input']>
lead?: InputMaybe<Scalars['String']['input']> lead?: InputMaybe<Scalars['String']['input']>
mainTopic?: InputMaybe<TopicInput>
media?: InputMaybe<Scalars['String']['input']> media?: InputMaybe<Scalars['String']['input']>
slug?: InputMaybe<Scalars['String']['input']> slug?: InputMaybe<Scalars['String']['input']>
subtitle?: InputMaybe<Scalars['String']['input']> subtitle?: InputMaybe<Scalars['String']['input']>

View File

@ -5,7 +5,7 @@ import { PRERENDERED_ARTICLES_COUNT } from '../../components/Views/Expo/Expo'
export const onBeforeRender = async (_pageContext: PageContext) => { export const onBeforeRender = async (_pageContext: PageContext) => {
const expoShouts = await apiClient.getShouts({ const expoShouts = await apiClient.getShouts({
filters: { excludeLayout: 'article' }, filters: { exclude_layout: 'article' },
limit: PRERENDERED_ARTICLES_COUNT limit: PRERENDERED_ARTICLES_COUNT
}) })
const pageProps: PageProps = { expoShouts } const pageProps: PageProps = { expoShouts }