mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #16236 from overleaf/ii-ide-page-prototype-review-panel-issues-2
[web] Enable track changes on page load in react ide page GitOrigin-RevId: 17e58490703c0d18fc700fde2e770e57a141a537
This commit is contained in:
parent
c2b553e915
commit
39e2a8349f
2 changed files with 42 additions and 26 deletions
|
@ -56,6 +56,10 @@ export type EditorManager = {
|
||||||
openDocs: OpenDocuments
|
openDocs: OpenDocuments
|
||||||
openInitialDoc: (docId: string) => void
|
openInitialDoc: (docId: string) => void
|
||||||
jumpToLine: (options: GotoLineOptions) => void
|
jumpToLine: (options: GotoLineOptions) => void
|
||||||
|
wantTrackChanges: boolean
|
||||||
|
setWantTrackChanges: React.Dispatch<
|
||||||
|
React.SetStateAction<EditorManager['wantTrackChanges']>
|
||||||
|
>
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasGotoLine(options: OpenDocOptions): options is GotoLineOptions {
|
function hasGotoLine(options: OpenDocOptions): options is GotoLineOptions {
|
||||||
|
@ -107,7 +111,14 @@ export const EditorManagerProvider: FC = ({ children }) => {
|
||||||
const [, setOpening] = useScopeValue<boolean>('editor.opening')
|
const [, setOpening] = useScopeValue<boolean>('editor.opening')
|
||||||
const [, setIsInErrorState] = useScopeValue<boolean>('editor.error_state')
|
const [, setIsInErrorState] = useScopeValue<boolean>('editor.error_state')
|
||||||
const [, setTrackChanges] = useScopeValue<boolean>('editor.trackChanges')
|
const [, setTrackChanges] = useScopeValue<boolean>('editor.trackChanges')
|
||||||
const [wantTrackChanges] = useScopeValue<boolean>('editor.wantTrackChanges')
|
const [wantTrackChanges, setWantTrackChanges] = useScopeValue<boolean>(
|
||||||
|
'editor.wantTrackChanges'
|
||||||
|
)
|
||||||
|
|
||||||
|
const wantTrackChangesRef = useRef(wantTrackChanges)
|
||||||
|
useEffect(() => {
|
||||||
|
wantTrackChangesRef.current = wantTrackChanges
|
||||||
|
}, [wantTrackChanges])
|
||||||
|
|
||||||
const goToLineEmitter = useScopeEventEmitter('editor:gotoLine')
|
const goToLineEmitter = useScopeEventEmitter('editor:gotoLine')
|
||||||
|
|
||||||
|
@ -275,9 +286,9 @@ export const EditorManagerProvider: FC = ({ children }) => {
|
||||||
syncTimeoutRef.current = null
|
syncTimeoutRef.current = null
|
||||||
}
|
}
|
||||||
|
|
||||||
const want = wantTrackChanges
|
const want = wantTrackChangesRef.current
|
||||||
const have = doc.getTrackingChanges()
|
const have = doc.getTrackingChanges()
|
||||||
if (wantTrackChanges === have) {
|
if (want === have) {
|
||||||
setTrackChanges(want)
|
setTrackChanges(want)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -285,7 +296,7 @@ export const EditorManagerProvider: FC = ({ children }) => {
|
||||||
const tryToggle = () => {
|
const tryToggle = () => {
|
||||||
const saved = doc.getInflightOp() == null && doc.getPendingOp() == null
|
const saved = doc.getInflightOp() == null && doc.getPendingOp() == null
|
||||||
if (saved) {
|
if (saved) {
|
||||||
doc.setTrackingChanges(wantTrackChanges)
|
doc.setTrackingChanges(want)
|
||||||
setTrackChanges(want)
|
setTrackChanges(want)
|
||||||
} else {
|
} else {
|
||||||
syncTimeoutRef.current = window.setTimeout(tryToggle, 100)
|
syncTimeoutRef.current = window.setTimeout(tryToggle, 100)
|
||||||
|
@ -294,7 +305,7 @@ export const EditorManagerProvider: FC = ({ children }) => {
|
||||||
|
|
||||||
tryToggle()
|
tryToggle()
|
||||||
},
|
},
|
||||||
[setTrackChanges, wantTrackChanges]
|
[setTrackChanges]
|
||||||
)
|
)
|
||||||
|
|
||||||
const doOpenNewDocument = useCallback(
|
const doOpenNewDocument = useCallback(
|
||||||
|
@ -598,6 +609,8 @@ export const EditorManagerProvider: FC = ({ children }) => {
|
||||||
openDocs,
|
openDocs,
|
||||||
openInitialDoc,
|
openInitialDoc,
|
||||||
jumpToLine,
|
jumpToLine,
|
||||||
|
wantTrackChanges,
|
||||||
|
setWantTrackChanges,
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
getEditorType,
|
getEditorType,
|
||||||
|
@ -613,6 +626,8 @@ export const EditorManagerProvider: FC = ({ children }) => {
|
||||||
openDocs,
|
openDocs,
|
||||||
openInitialDoc,
|
openInitialDoc,
|
||||||
jumpToLine,
|
jumpToLine,
|
||||||
|
wantTrackChanges,
|
||||||
|
setWantTrackChanges,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -132,11 +132,16 @@ function useReviewPanelState(): ReviewPanelStateReactIde {
|
||||||
features: { trackChangesVisible, trackChanges },
|
features: { trackChangesVisible, trackChanges },
|
||||||
} = project
|
} = project
|
||||||
const { isRestrictedTokenMember } = useEditorContext()
|
const { isRestrictedTokenMember } = useEditorContext()
|
||||||
const { openDocId, currentDocument, currentDocumentId } =
|
const {
|
||||||
useEditorManagerContext() as MergeAndOverride<
|
openDocId,
|
||||||
EditorManager,
|
currentDocument,
|
||||||
{ currentDocumentId: DocId }
|
currentDocumentId,
|
||||||
>
|
wantTrackChanges,
|
||||||
|
setWantTrackChanges,
|
||||||
|
} = useEditorManagerContext() as MergeAndOverride<
|
||||||
|
EditorManager,
|
||||||
|
{ currentDocumentId: DocId }
|
||||||
|
>
|
||||||
// TODO permissions to be removed from the review panel context. It currently acts just as a proxy.
|
// TODO permissions to be removed from the review panel context. It currently acts just as a proxy.
|
||||||
const permissions = usePermissionsContext()
|
const permissions = usePermissionsContext()
|
||||||
const { showGenericMessageModal } = useModalsContext()
|
const { showGenericMessageModal } = useModalsContext()
|
||||||
|
@ -168,9 +173,6 @@ function useReviewPanelState(): ReviewPanelStateReactIde {
|
||||||
ReviewPanel.Value<'resolvedComments'>
|
ReviewPanel.Value<'resolvedComments'>
|
||||||
>({})
|
>({})
|
||||||
|
|
||||||
const [wantTrackChanges, setWantTrackChanges] = useScopeValue<
|
|
||||||
ReviewPanel.Value<'wantTrackChanges'>
|
|
||||||
>('editor.wantTrackChanges')
|
|
||||||
const [shouldCollapse, setShouldCollapse] =
|
const [shouldCollapse, setShouldCollapse] =
|
||||||
useState<ReviewPanel.Value<'shouldCollapse'>>(true)
|
useState<ReviewPanel.Value<'shouldCollapse'>>(true)
|
||||||
const [lineHeight, setLineHeight] =
|
const [lineHeight, setLineHeight] =
|
||||||
|
@ -806,20 +808,19 @@ function useReviewPanelState(): ReviewPanelStateReactIde {
|
||||||
project.owner
|
project.owner
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (project.members) {
|
const members = project.members ?? []
|
||||||
for (const member of project.members) {
|
for (const member of members) {
|
||||||
if (member.privileges === 'readAndWrite') {
|
if (member.privileges === 'readAndWrite') {
|
||||||
if (!trackChangesState[member._id]) {
|
if (!trackChangesState[member._id]) {
|
||||||
// An added member will have track changes enabled if track changes is on for everyone
|
// An added member will have track changes enabled if track changes is on for everyone
|
||||||
setUserTCState(
|
setUserTCState(
|
||||||
trackChangesState,
|
trackChangesState,
|
||||||
member._id,
|
member._id,
|
||||||
trackChangesOnForEveryone,
|
trackChangesOnForEveryone,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
}
|
|
||||||
tempFormattedProjectMembers[member._id] = formatUser(member)
|
|
||||||
}
|
}
|
||||||
|
tempFormattedProjectMembers[member._id] = formatUser(member)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tempFormattedProjectMembers
|
return tempFormattedProjectMembers
|
||||||
|
|
Loading…
Reference in a new issue