mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Remove savedAt from compiler (#16642)
GitOrigin-RevId: 526d26d731da99b40c253a4dc0a774a896641c8e
This commit is contained in:
parent
bc7201e337
commit
11859f1c38
3 changed files with 5 additions and 26 deletions
|
@ -68,16 +68,4 @@ export default function useCompileTriggers(
|
|||
setOrTriggerChangedAt(Date.now())
|
||||
}, [setOrTriggerChangedAt])
|
||||
useEventListener('doc:changed', setChangedAtHandler)
|
||||
|
||||
// record when the server acknowledges saving changes
|
||||
const setOrTriggerSavedAt = useDetachAction(
|
||||
'set-saved-at',
|
||||
setSavedAt,
|
||||
'detacher',
|
||||
'detached'
|
||||
)
|
||||
const setSavedAtHandler = useCallback(() => {
|
||||
setOrTriggerSavedAt(Date.now())
|
||||
}, [setOrTriggerSavedAt])
|
||||
useEventListener('doc:saved', setSavedAtHandler)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ export default class DocumentCompiler {
|
|||
compilingRef,
|
||||
projectId,
|
||||
setChangedAt,
|
||||
setSavedAt,
|
||||
setCompiling,
|
||||
setData,
|
||||
setFirstRenderDone,
|
||||
|
@ -35,7 +34,6 @@ export default class DocumentCompiler {
|
|||
this.compilingRef = compilingRef
|
||||
this.projectId = projectId
|
||||
this.setChangedAt = setChangedAt
|
||||
this.setSavedAt = setSavedAt
|
||||
this.setCompiling = setCompiling
|
||||
this.setData = setData
|
||||
this.setFirstRenderDone = setFirstRenderDone
|
||||
|
@ -82,7 +80,7 @@ export default class DocumentCompiler {
|
|||
return resolve()
|
||||
}
|
||||
|
||||
this._onDocSavedCallback = docSavedParams => {
|
||||
this._onDocSavedCallback = () => {
|
||||
// TODO: it's possible that there's more than one doc open with buffered ops, and ideally we'd wait for all docs to be flushed
|
||||
removeEventListener()
|
||||
resolve()
|
||||
|
@ -124,7 +122,6 @@ export default class DocumentCompiler {
|
|||
|
||||
// reset values
|
||||
this.setChangedAt(0) // TODO: wait for doc:saved?
|
||||
this.setSavedAt(0)
|
||||
this.validationIssues = undefined
|
||||
|
||||
const params = this.buildCompileParams(options)
|
||||
|
|
|
@ -254,9 +254,6 @@ export const LocalCompileProvider: FC = ({ children }) => {
|
|||
// the timestamp that a doc was last changed
|
||||
const [changedAt, setChangedAt] = useState(0)
|
||||
|
||||
// the timestamp that a doc was last saved
|
||||
const [savedAt, setSavedAt] = useState(0)
|
||||
|
||||
const { signal } = useAbortController()
|
||||
|
||||
const cleanupCompileResult = useCallback(() => {
|
||||
|
@ -288,7 +285,6 @@ export const LocalCompileProvider: FC = ({ children }) => {
|
|||
return new DocumentCompiler({
|
||||
projectId,
|
||||
setChangedAt,
|
||||
setSavedAt,
|
||||
setCompiling,
|
||||
setData,
|
||||
setFirstRenderDone,
|
||||
|
@ -321,8 +317,8 @@ export const LocalCompileProvider: FC = ({ children }) => {
|
|||
}, [compiler, stopOnFirstError])
|
||||
|
||||
useEffect(() => {
|
||||
setUncompiled(changedAt > 0 || savedAt > 0)
|
||||
}, [setUncompiled, changedAt, savedAt])
|
||||
setUncompiled(changedAt > 0)
|
||||
}, [setUncompiled, changedAt])
|
||||
|
||||
useEffect(() => {
|
||||
setEditedSinceCompileStarted(changedAt > 0)
|
||||
|
@ -530,13 +526,13 @@ export const LocalCompileProvider: FC = ({ children }) => {
|
|||
// call the debounced autocompile function if the project is available for auto-compiling and it has changed
|
||||
useEffect(() => {
|
||||
if (canAutoCompile) {
|
||||
if (changedAt > 0 || savedAt > 0) {
|
||||
if (changedAt > 0) {
|
||||
compiler.debouncedAutoCompile()
|
||||
}
|
||||
} else {
|
||||
compiler.debouncedAutoCompile.cancel()
|
||||
}
|
||||
}, [compiler, canAutoCompile, changedAt, savedAt])
|
||||
}, [compiler, canAutoCompile, changedAt])
|
||||
|
||||
// cancel debounced recompile on unmount
|
||||
useEffect(() => {
|
||||
|
@ -651,7 +647,6 @@ export const LocalCompileProvider: FC = ({ children }) => {
|
|||
validationIssues,
|
||||
firstRenderDone,
|
||||
setChangedAt,
|
||||
setSavedAt,
|
||||
cleanupCompileResult,
|
||||
syncToEntry,
|
||||
}),
|
||||
|
@ -702,7 +697,6 @@ export const LocalCompileProvider: FC = ({ children }) => {
|
|||
validationIssues,
|
||||
firstRenderDone,
|
||||
setChangedAt,
|
||||
setSavedAt,
|
||||
cleanupCompileResult,
|
||||
setShowLogs,
|
||||
toggleLogs,
|
||||
|
|
Loading…
Reference in a new issue