mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Tidy up global scope values (#20379)
* Remove crypto from window * Remove ui.loadingStyleSheet * Remove onlineUsers scope * Remove addNewComment GitOrigin-RevId: 5e62ed7f265cdd530b5ca85488477093b0be775a
This commit is contained in:
@@ -85,20 +85,6 @@ function hasGotoOffset(options: OpenDocOptions): options is GotoOffsetOptions {
|
||||
return typeof options.gotoOffset === 'number'
|
||||
}
|
||||
|
||||
export type EditorScopeValue = {
|
||||
showSymbolPalette: false
|
||||
toggleSymbolPalette: () => void
|
||||
sharejs_doc: DocumentContainer | null
|
||||
open_doc_id: string | null
|
||||
open_doc_name: string | null
|
||||
opening: boolean
|
||||
trackChanges: boolean
|
||||
wantTrackChanges: boolean
|
||||
showVisual: boolean
|
||||
newSourceEditor: boolean
|
||||
error_state: boolean
|
||||
}
|
||||
|
||||
export const EditorManagerContext = createContext<EditorManager | undefined>(
|
||||
undefined
|
||||
)
|
||||
|
||||
@@ -20,7 +20,6 @@ import { useConnectionContext } from '@/features/ide-react/context/connection-co
|
||||
import { getMockIde } from '@/shared/context/mock/mock-ide'
|
||||
import { populateEditorScope } from '@/features/ide-react/scope-adapters/editor-manager-context-adapter'
|
||||
import { postJSON } from '@/infrastructure/fetch-json'
|
||||
import { populateOnlineUsersScope } from '@/features/ide-react/context/online-users-context'
|
||||
import { ReactScopeEventEmitter } from '@/features/ide-react/scope-event-emitter/react-scope-event-emitter'
|
||||
import getMeta from '@/utils/meta'
|
||||
|
||||
@@ -74,7 +73,6 @@ export function createReactScopeValueStore(projectId: string) {
|
||||
populateLayoutScope(scopeStore)
|
||||
populateProjectScope(scopeStore)
|
||||
populatePdfScope(scopeStore)
|
||||
populateOnlineUsersScope(scopeStore)
|
||||
populateReviewPanelScope(scopeStore)
|
||||
|
||||
scopeStore.allowNonExistentPath('hasLintingError')
|
||||
|
||||
@@ -7,10 +7,8 @@ import {
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react'
|
||||
import { ReactScopeValueStore } from '@/features/ide-react/scope-value-store/react-scope-value-store'
|
||||
import { useIdeReactContext } from '@/features/ide-react/context/ide-react-context'
|
||||
import { useConnectionContext } from '@/features/ide-react/context/connection-context'
|
||||
import useScopeValue from '@/shared/hooks/use-scope-value'
|
||||
import { CursorPosition } from '@/features/ide-react/types/cursor-position'
|
||||
import { omit } from 'lodash'
|
||||
import { Doc } from '../../../../../types/doc'
|
||||
@@ -63,16 +61,9 @@ type OnlineUsersContextValue = {
|
||||
onlineUsersCount: number
|
||||
}
|
||||
|
||||
export function populateOnlineUsersScope(store: ReactScopeValueStore) {
|
||||
store.set('onlineUsers', {})
|
||||
store.set('onlineUserCursorHighlights', {})
|
||||
store.set('onlineUsersArray', [])
|
||||
store.set('onlineUsersCount', 0)
|
||||
}
|
||||
|
||||
const OnlineUsersContext = createContext<OnlineUsersContextValue | undefined>(
|
||||
undefined
|
||||
)
|
||||
export const OnlineUsersContext = createContext<
|
||||
OnlineUsersContextValue | undefined
|
||||
>(undefined)
|
||||
|
||||
export const OnlineUsersProvider: FC = ({ children }) => {
|
||||
const { eventEmitter } = useIdeReactContext()
|
||||
@@ -80,20 +71,12 @@ export const OnlineUsersProvider: FC = ({ children }) => {
|
||||
const { currentDocumentId } = useEditorManagerContext()
|
||||
const { fileTreeData } = useFileTreeData()
|
||||
|
||||
const [onlineUsers, setOnlineUsers] =
|
||||
useScopeValue<OnlineUsersContextValue['onlineUsers']>('onlineUsers')
|
||||
const [onlineUserCursorHighlights, setOnlineUserCursorHighlights] =
|
||||
useScopeValue<OnlineUsersContextValue['onlineUserCursorHighlights']>(
|
||||
'onlineUserCursorHighlights'
|
||||
)
|
||||
const [onlineUsersArray, setOnlineUsersArray] =
|
||||
useScopeValue<OnlineUsersContextValue['onlineUsersArray']>(
|
||||
'onlineUsersArray'
|
||||
)
|
||||
const [onlineUsersCount, setOnlineUsersCount] =
|
||||
useScopeValue<OnlineUsersContextValue['onlineUsersCount']>(
|
||||
'onlineUsersCount'
|
||||
)
|
||||
const [onlineUsers, setOnlineUsers] = useState<Record<string, OnlineUser>>({})
|
||||
const [onlineUserCursorHighlights, setOnlineUserCursorHighlights] = useState<
|
||||
Record<string, CursorHighlight[]>
|
||||
>({})
|
||||
const [onlineUsersArray, setOnlineUsersArray] = useState<OnlineUser[]>([])
|
||||
const [onlineUsersCount, setOnlineUsersCount] = useState(0)
|
||||
|
||||
const [currentPosition, setCurrentPosition] = useState<CursorPosition | null>(
|
||||
null
|
||||
|
||||
@@ -73,8 +73,8 @@ export const ReactContextRoot: FC<{ providers?: Record<string, FC> }> = ({
|
||||
<Providers.DetachProvider>
|
||||
<Providers.EditorProvider>
|
||||
<Providers.PermissionsProvider>
|
||||
<Providers.ProjectSettingsProvider>
|
||||
<Providers.LayoutProvider>
|
||||
<Providers.LayoutProvider>
|
||||
<Providers.ProjectSettingsProvider>
|
||||
<Providers.EditorManagerProvider>
|
||||
<Providers.LocalCompileProvider>
|
||||
<Providers.DetachCompileProvider>
|
||||
@@ -94,8 +94,8 @@ export const ReactContextRoot: FC<{ providers?: Record<string, FC> }> = ({
|
||||
</Providers.DetachCompileProvider>
|
||||
</Providers.LocalCompileProvider>
|
||||
</Providers.EditorManagerProvider>
|
||||
</Providers.LayoutProvider>
|
||||
</Providers.ProjectSettingsProvider>
|
||||
</Providers.ProjectSettingsProvider>
|
||||
</Providers.LayoutProvider>
|
||||
</Providers.PermissionsProvider>
|
||||
</Providers.EditorProvider>
|
||||
</Providers.DetachProvider>
|
||||
|
||||
Reference in New Issue
Block a user