diff --git a/web/src/ui/MessageComposer.tsx b/web/src/ui/MessageComposer.tsx
new file mode 100644
index 0000000..fe2f95b
--- /dev/null
+++ b/web/src/ui/MessageComposer.tsx
@@ -0,0 +1,45 @@
+// gomuks - A Matrix client written in Go.
+// Copyright (C) 2024 Tulir Asokan
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+import React, { use, useCallback, useState } from "react"
+import { RoomStateStore } from "../api/statestore.ts"
+import { ClientContext } from "./ClientContext.ts"
+
+interface MessageComposerProps {
+ room: RoomStateStore
+}
+
+const MessageComposer = ({ room }: MessageComposerProps) => {
+ const client = use(ClientContext)!
+ const [text, setText] = useState("")
+ const sendMessage = useCallback((evt: React.FormEvent) => {
+ evt.preventDefault()
+ setText("")
+ client.rpc.sendMessage(room.roomID, text)
+ .catch(err => window.alert("Failed to send message: " + err))
+ }, [text, room, client])
+ return
+}
+
+export default MessageComposer
diff --git a/web/src/ui/RoomView.tsx b/web/src/ui/RoomView.tsx
index b2774fd..34495e1 100644
--- a/web/src/ui/RoomView.tsx
+++ b/web/src/ui/RoomView.tsx
@@ -13,11 +13,10 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-import React, { use, useState } from "react"
import { getMediaURL } from "../api/media.ts"
import { RoomStateStore } from "../api/statestore.ts"
import { useNonNullEventAsState } from "../util/eventdispatcher.ts"
-import { ClientContext } from "./ClientContext.ts"
+import MessageComposer from "./MessageComposer.tsx"
import TimelineView from "./timeline/TimelineView.tsx"
import "./RoomView.css"
@@ -25,39 +24,26 @@ interface RoomViewProps {
room: RoomStateStore
}
-const RoomView = ({ room }: RoomViewProps) => {
- const [text, setText] = useState("")
- const client = use(ClientContext)!
+const RoomHeader = ({ room }: RoomViewProps) => {
const roomMeta = useNonNullEventAsState(room.meta)
- const sendMessage = (evt: React.FormEvent) => {
- evt.preventDefault()
- setText("")
- client.rpc.sendMessage(room.roomID, text)
- .catch(err => window.alert("Failed to send message: " + err))
- }
+ return
+
})
+
+ {roomMeta.name ?? roomMeta.room_id}
+
+
+}
+
+const RoomView = ({ room }: RoomViewProps) => {
return
-
-
})
-
- {roomMeta.name ?? roomMeta.room_id}
-
-
+
-
+
}