Fix: hook being used inside useEffect (#21534)
This commit is contained in:
parent
bf3cd7a5d5
commit
988ae28d42
@ -93,22 +93,10 @@ const ActionsBarContainer = (props) => {
|
||||
const amIPresenter = currentUserData?.presenter;
|
||||
const amIModerator = currentUserData?.isModerator;
|
||||
const [pinnedPadDataState, setPinnedPadDataState] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
const { data: pinnedPadData } = await useDeduplicatedSubscription(
|
||||
const { data: pinnedPadData } = useDeduplicatedSubscription(
|
||||
PINNED_PAD_SUBSCRIPTION,
|
||||
);
|
||||
setPinnedPadDataState(pinnedPadData || []);
|
||||
};
|
||||
|
||||
fetchData();
|
||||
}, []);
|
||||
|
||||
const isSharedNotesPinnedFromGraphql = !!pinnedPadDataState
|
||||
&& pinnedPadDataState.sharedNotes[0]?.sharedNotesExtId === NOTES_CONFIG.id;
|
||||
|
||||
const isSharedNotesPinned = isSharedNotesPinnedFromGraphql;
|
||||
const allowExternalVideo = useIsExternalVideoEnabled();
|
||||
const connected = useReactiveVar(connectionStatus.getConnectedStatusVar());
|
||||
const intl = useIntl();
|
||||
@ -131,7 +119,12 @@ const ActionsBarContainer = (props) => {
|
||||
&& (deviceInfo.isPhone || isLayeredView.matches);
|
||||
if (actionsBarStyle.display === false) return null;
|
||||
if (!currentMeeting) return null;
|
||||
if (!pinnedPadData) return null;
|
||||
|
||||
const isSharedNotesPinnedFromGraphql = !!pinnedPadData
|
||||
&& pinnedPadData.sharedNotes[0]?.sharedNotesExtId === NOTES_CONFIG.id;
|
||||
|
||||
const isSharedNotesPinned = isSharedNotesPinnedFromGraphql;
|
||||
return (
|
||||
<ActionsBar {
|
||||
...{
|
||||
|
@ -191,30 +191,13 @@ const UserNotesGraphql: React.FC<UserNotesGraphqlProps> = (props) => {
|
||||
};
|
||||
|
||||
const UserNotesContainerGraphql: React.FC<UserNotesContainerGraphqlProps> = (props) => {
|
||||
type PinnedPadData = {
|
||||
sharedNotes: Array<{
|
||||
sharedNotesExtId: string;
|
||||
}>;
|
||||
};
|
||||
const { userLocks } = props;
|
||||
const disableNotes = userLocks.userNotes;
|
||||
const [pinnedPadDataState, setPinnedPadDataState] = useState<PinnedPadData | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
const { data: pinnedPadData } = await useDeduplicatedSubscription(
|
||||
const { data: pinnedPadData } = useDeduplicatedSubscription(
|
||||
PINNED_PAD_SUBSCRIPTION,
|
||||
);
|
||||
setPinnedPadDataState(pinnedPadData || []);
|
||||
};
|
||||
|
||||
fetchData();
|
||||
}, []);
|
||||
|
||||
const NOTES_CONFIG = window.meetingClientSettings.public.notes;
|
||||
|
||||
const isPinned = !!pinnedPadDataState && pinnedPadDataState.sharedNotes[0]?.sharedNotesExtId === NOTES_CONFIG.id;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const sidebarContent = layoutSelectInput((i: any) => i.sidebarContent);
|
||||
const { sidebarContentPanel } = sidebarContent;
|
||||
@ -226,7 +209,9 @@ const UserNotesContainerGraphql: React.FC<UserNotesContainerGraphqlProps> = (pro
|
||||
const hasUnreadNotes = useHasUnreadNotes();
|
||||
const markNotesAsRead = () => setNotesLastRev(rev);
|
||||
const isEnabled = NotesService.useIsEnabled();
|
||||
if (!pinnedPadData) return null;
|
||||
|
||||
const isPinned = !!pinnedPadData && pinnedPadData?.sharedNotes[0]?.sharedNotesExtId === NOTES_CONFIG.id;
|
||||
return (
|
||||
<UserNotesGraphql
|
||||
disableNotes={disableNotes}
|
||||
|
Loading…
Reference in New Issue
Block a user