({
thread: initialThread,
currentChannel,
currentCommunity,
isBot,
isSubDomainRouting,
settings,
permissions,
useJoinContext,
useUsersContext,
api,
fetchMentions,
}: Props)
| 33 | } |
| 34 | |
| 35 | export default function Content({ |
| 36 | thread: initialThread, |
| 37 | currentChannel, |
| 38 | currentCommunity, |
| 39 | isBot, |
| 40 | isSubDomainRouting, |
| 41 | settings, |
| 42 | permissions, |
| 43 | useJoinContext, |
| 44 | useUsersContext, |
| 45 | api, |
| 46 | fetchMentions, |
| 47 | }: Props) { |
| 48 | const [thread, setThread] = useState<SerializedThread>(initialThread); |
| 49 | const [allUsers] = useUsersContext(); |
| 50 | const { startSignUp } = useJoinContext(); |
| 51 | |
| 52 | const token = permissions.token || null; |
| 53 | const currentUser = permissions.user; |
| 54 | |
| 55 | const onThreadMessage = ( |
| 56 | threadId: string, |
| 57 | message: SerializedMessage, |
| 58 | messageId: string, |
| 59 | imitationId: string |
| 60 | ) => { |
| 61 | setThread((thread: SerializedThread) => { |
| 62 | if (thread.id === threadId) { |
| 63 | return { |
| 64 | ...thread, |
| 65 | messages: [ |
| 66 | ...thread.messages.filter( |
| 67 | ({ id }: any) => id !== imitationId && id !== messageId |
| 68 | ), |
| 69 | message, |
| 70 | ], |
| 71 | }; |
| 72 | } |
| 73 | return thread; |
| 74 | }); |
| 75 | }; |
| 76 | |
| 77 | const updateThread = ({ |
| 78 | state: newState, |
| 79 | title: newTitle, |
| 80 | }: { |
| 81 | state?: ThreadState; |
| 82 | title?: string; |
| 83 | }) => { |
| 84 | const options = { |
| 85 | state: newState || thread.state, |
| 86 | title: newTitle || thread.title || undefined, |
| 87 | }; |
| 88 | setThread((thread: SerializedThread) => { |
| 89 | return { |
| 90 | ...thread, |
| 91 | ...options, |
| 92 | }; |
nothing calls this directly
no test coverage detected