Skip to content

Commit

Permalink
fix(collaborate): blocked user shouldn't be able to edit transcript
Browse files Browse the repository at this point in the history
  • Loading branch information
nonumpa committed Jan 10, 2024
1 parent 20083e3 commit b9cc03d
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions components/Collaborate/CollabEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import useCurrentUser from 'lib/useCurrentUser';
import PlaceholderPlugin from './Placeholder';
import getConfig from 'next/config';
import CollabHistory from './CollabHistory';
import { useIsUserBlocked } from 'lib/isUserBlocked';

const {
publicRuntimeConfig: { PUBLIC_COLLAB_SERVER_URL },
Expand Down Expand Up @@ -139,6 +140,7 @@ const CollabEditor = ({ article }) => {
const [showEditor, setShowEditor] = useState(null);
const [isSynced, setIsSynced] = useState(false);
const currentUser = useCurrentUser();
const isUserBlocked = useIsUserBlocked();

// onTranscribe setup provider for both Editor and CollabHistory to use.
// And, to avoid duplicated connection, provider will be destroyed(close connection) when Editor unmounted.
Expand Down Expand Up @@ -208,7 +210,7 @@ const CollabEditor = ({ article }) => {
>
{t`No transcripts yet`}
</Typography>
{!showEditor ? (
{!showEditor && !isUserBlocked ? (
<>
<Button
color="primary"
Expand All @@ -232,20 +234,23 @@ const CollabEditor = ({ article }) => {
>
{t`Transcript`}
</Typography>
{!showEditor ? (
<Button
variant="outlined"
className={classes.editButton}
onClick={onTranscribe}
>
<TranscribePenIcon className={classes.newReplyFabIcon} />
{t`Edit`}
</Button>
) : (
isSynced && (
<CollabHistory ydoc={provider.document} docName={article.id} />
)
)}
{!showEditor
? !isUserBlocked && (
<Button
variant="outlined"
className={classes.editButton}
onClick={onTranscribe}
>
<TranscribePenIcon className={classes.newReplyFabIcon} />
{t`Edit`}
</Button>
)
: isSynced && (
<CollabHistory
ydoc={provider.document}
docName={article.id}
/>
)}
</>
)}
</div>
Expand Down

0 comments on commit b9cc03d

Please sign in to comment.