chat: hide input if unable to write
@@ -13,6 +13,7 @@ import SubmitDragger from '~/views/components/SubmitDragger';
import { useLocalStorageState } from '~/logic/lib/useLocalStorageState';
import { Loading } from '~/views/components/Loading';
import useS3 from '~/logic/lib/useS3';
+import {isWriter} from '~/logic/lib/group';
type ChatResourceProps = StoreState & {
association: Association;
@@ -37,6 +38,8 @@ export function ChatResource(props: ChatResourceProps) {
const chatInput = useRef<ChatInput>();
+ const canWrite = isWriter(group, station);
+
useEffect(() => {
const count = Math.min(50, unreadCount + 15);
props.api.graph.getNewest(owner, name, count);
@@ -107,6 +110,7 @@ export function ChatResource(props: ChatResourceProps) {
location={props.location}
scrollTo={scrollTo ? parseInt(scrollTo, 10) : undefined}
/>
+ { canWrite && (
<ChatInput
ref={chatInput}
api={props.api}
@@ -119,7 +123,7 @@ export function ChatResource(props: ChatResourceProps) {
placeholder="Message..."
message={unsent[station] || ''}
deleteMessage={clearUnsent}
- />
+ /> )}
</Col>
);
}
