diff --git a/src/app/features/room/RoomTrainingLine.tsx b/src/app/features/room/RoomTrainingLine.tsx new file mode 100644 index 00000000..147932de --- /dev/null +++ b/src/app/features/room/RoomTrainingLine.tsx @@ -0,0 +1,25 @@ +import { Text, color, config } from 'folds'; +import { Room } from 'matrix-js-sdk'; +import React from 'react'; +import { useStateEvent } from '../../hooks/useStateEvent'; +import { + ROOM_NOTICE_EVENT_TYPE, + parseRoomNotice, + roomTrainingLine, +} from '../../utils/trainingNotice'; + +// The room's notice state event decides the line; no event, or a malformed one, no line. The +// collector reads the version from the same event, so nothing is stored in the browser. +export function RoomTrainingLine({ room }: { room: Room }) { + const event = useStateEvent(room, ROOM_NOTICE_EVENT_TYPE); + const line = roomTrainingLine(parseRoomNotice(event?.getContent())); + if (!line) return null; + return ( + + {line} + + ); +} diff --git a/src/app/features/room/RoomView.tsx b/src/app/features/room/RoomView.tsx index a4f0d7af..3fbd81fa 100644 --- a/src/app/features/room/RoomView.tsx +++ b/src/app/features/room/RoomView.tsx @@ -13,6 +13,7 @@ import { RoomTimeline } from './RoomTimeline'; import { RoomViewTyping } from './RoomViewTyping'; import { RoomTombstone } from './RoomTombstone'; import { RoomInput } from './RoomInput'; +import { RoomTrainingLine } from './RoomTrainingLine'; import { RoomViewFollowing, RoomViewFollowingPlaceholder } from './RoomViewFollowing'; import { Page } from '../../components/page'; import { useKeyDown } from '../../hooks/useKeyDown'; @@ -104,6 +105,7 @@ export function RoomView({ eventId }: { eventId?: string }) {
+ {tombstoneEvent ? ( void; +}; + +// Registration only: ticking it is the newcomer's acceptance of the current notice version. +export function TrainingNotice({ checked, onToggle }: TrainingNoticeProps) { + return ( + + + + {TRAINING_NOTICE_TEXT} + + + ); +} diff --git a/src/app/pages/auth/register/PasswordRegisterForm.tsx b/src/app/pages/auth/register/PasswordRegisterForm.tsx index c9b1924c..99feed1a 100644 --- a/src/app/pages/auth/register/PasswordRegisterForm.tsx +++ b/src/app/pages/auth/register/PasswordRegisterForm.tsx @@ -32,6 +32,7 @@ import { AsyncState, AsyncStatus, useAsyncCallback } from '../../../hooks/useAsy import { useAutoDiscoveryInfo } from '../../../hooks/useAutoDiscoveryInfo'; import { RegisterError, RegisterResult, register, useRegisterComplete } from './registerUtil'; import { FieldError } from '../FiledError'; +import { TrainingNotice } from '../TrainingNotice'; import { AutoDummyStageDialog, AutoTermsStageDialog, @@ -192,6 +193,7 @@ export function PasswordRegisterForm({ const [formData, setFormData] = useState(); const [ongoingFlow, setOngoingFlow] = useState(); + const [trainingAck, setTrainingAck] = useState(false); const [registerEmailState, registerEmail] = useRegisterEmail(mx); @@ -389,7 +391,8 @@ export function PasswordRegisterForm({ )} -