Remove savedAt from compiler (#16642)

GitOrigin-RevId: 526d26d731da99b40c253a4dc0a774a896641c8e
This commit is contained in:
Alf Eaton 2024-01-26 09:26:31 +00:00 committed by Copybot
parent bc7201e337
commit 11859f1c38
3 changed files with 5 additions and 26 deletions

View file

@ -68,16 +68,4 @@ export default function useCompileTriggers(
setOrTriggerChangedAt(Date.now()) setOrTriggerChangedAt(Date.now())
}, [setOrTriggerChangedAt]) }, [setOrTriggerChangedAt])
useEventListener('doc:changed', setChangedAtHandler) 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)
} }

View file

@ -23,7 +23,6 @@ export default class DocumentCompiler {
compilingRef, compilingRef,
projectId, projectId,
setChangedAt, setChangedAt,
setSavedAt,
setCompiling, setCompiling,
setData, setData,
setFirstRenderDone, setFirstRenderDone,
@ -35,7 +34,6 @@ export default class DocumentCompiler {
this.compilingRef = compilingRef this.compilingRef = compilingRef
this.projectId = projectId this.projectId = projectId
this.setChangedAt = setChangedAt this.setChangedAt = setChangedAt
this.setSavedAt = setSavedAt
this.setCompiling = setCompiling this.setCompiling = setCompiling
this.setData = setData this.setData = setData
this.setFirstRenderDone = setFirstRenderDone this.setFirstRenderDone = setFirstRenderDone
@ -82,7 +80,7 @@ export default class DocumentCompiler {
return resolve() 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 // 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() removeEventListener()
resolve() resolve()
@ -124,7 +122,6 @@ export default class DocumentCompiler {
// reset values // reset values
this.setChangedAt(0) // TODO: wait for doc:saved? this.setChangedAt(0) // TODO: wait for doc:saved?
this.setSavedAt(0)
this.validationIssues = undefined this.validationIssues = undefined
const params = this.buildCompileParams(options) const params = this.buildCompileParams(options)

View file

@ -254,9 +254,6 @@ export const LocalCompileProvider: FC = ({ children }) => {
// the timestamp that a doc was last changed // the timestamp that a doc was last changed
const [changedAt, setChangedAt] = useState(0) const [changedAt, setChangedAt] = useState(0)
// the timestamp that a doc was last saved
const [savedAt, setSavedAt] = useState(0)
const { signal } = useAbortController() const { signal } = useAbortController()
const cleanupCompileResult = useCallback(() => { const cleanupCompileResult = useCallback(() => {
@ -288,7 +285,6 @@ export const LocalCompileProvider: FC = ({ children }) => {
return new DocumentCompiler({ return new DocumentCompiler({
projectId, projectId,
setChangedAt, setChangedAt,
setSavedAt,
setCompiling, setCompiling,
setData, setData,
setFirstRenderDone, setFirstRenderDone,
@ -321,8 +317,8 @@ export const LocalCompileProvider: FC = ({ children }) => {
}, [compiler, stopOnFirstError]) }, [compiler, stopOnFirstError])
useEffect(() => { useEffect(() => {
setUncompiled(changedAt > 0 || savedAt > 0) setUncompiled(changedAt > 0)
}, [setUncompiled, changedAt, savedAt]) }, [setUncompiled, changedAt])
useEffect(() => { useEffect(() => {
setEditedSinceCompileStarted(changedAt > 0) 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 // call the debounced autocompile function if the project is available for auto-compiling and it has changed
useEffect(() => { useEffect(() => {
if (canAutoCompile) { if (canAutoCompile) {
if (changedAt > 0 || savedAt > 0) { if (changedAt > 0) {
compiler.debouncedAutoCompile() compiler.debouncedAutoCompile()
} }
} else { } else {
compiler.debouncedAutoCompile.cancel() compiler.debouncedAutoCompile.cancel()
} }
}, [compiler, canAutoCompile, changedAt, savedAt]) }, [compiler, canAutoCompile, changedAt])
// cancel debounced recompile on unmount // cancel debounced recompile on unmount
useEffect(() => { useEffect(() => {
@ -651,7 +647,6 @@ export const LocalCompileProvider: FC = ({ children }) => {
validationIssues, validationIssues,
firstRenderDone, firstRenderDone,
setChangedAt, setChangedAt,
setSavedAt,
cleanupCompileResult, cleanupCompileResult,
syncToEntry, syncToEntry,
}), }),
@ -702,7 +697,6 @@ export const LocalCompileProvider: FC = ({ children }) => {
validationIssues, validationIssues,
firstRenderDone, firstRenderDone,
setChangedAt, setChangedAt,
setSavedAt,
cleanupCompileResult, cleanupCompileResult,
setShowLogs, setShowLogs,
toggleLogs, toggleLogs,