mirror of
https://github.com/misode/misode.github.io.git
synced 2026-05-02 21:52:54 +00:00
Fix history index tracking
This commit is contained in:
@@ -31,6 +31,7 @@ export function VersionProvider({ children }: { children: ComponentChildren }) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (VersionIds.includes(targetVersion as VersionId) && version !== targetVersion) {
|
if (VersionIds.includes(targetVersion as VersionId) && version !== targetVersion) {
|
||||||
|
Analytics.setVersion(targetVersion as VersionId)
|
||||||
setVersion(targetVersion as VersionId)
|
setVersion(targetVersion as VersionId)
|
||||||
}
|
}
|
||||||
}, [version, targetVersion])
|
}, [version, targetVersion])
|
||||||
@@ -46,6 +47,10 @@ export function VersionProvider({ children }: { children: ComponentChildren }) {
|
|||||||
setVersion(newVersion)
|
setVersion(newVersion)
|
||||||
}, [targetVersion])
|
}, [targetVersion])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
Analytics.setVersion(version)
|
||||||
|
}, [])
|
||||||
|
|
||||||
const value: Version = {
|
const value: Version = {
|
||||||
version,
|
version,
|
||||||
changeVersion,
|
changeVersion,
|
||||||
|
|||||||
@@ -168,21 +168,21 @@ export function Generator({}: Props) {
|
|||||||
}
|
}
|
||||||
const undo = (e: MouseEvent) => {
|
const undo = (e: MouseEvent) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
Analytics.undoGenerator(gen.id, (model?.historyIndex ?? 1) - 1, 'menu')
|
Analytics.undoGenerator(gen.id, model?.historyIndex ?? 1, 'menu')
|
||||||
model?.undo()
|
model?.undo()
|
||||||
}
|
}
|
||||||
const redo = (e: MouseEvent) => {
|
const redo = (e: MouseEvent) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
Analytics.redoGenerator(gen.id, (model?.historyIndex ?? 1) + 1, 'menu')
|
Analytics.redoGenerator(gen.id, model?.historyIndex ?? 1, 'menu')
|
||||||
model?.redo()
|
model?.redo()
|
||||||
}
|
}
|
||||||
|
|
||||||
const onKeyUp = (e: KeyboardEvent) => {
|
const onKeyUp = (e: KeyboardEvent) => {
|
||||||
if (e.ctrlKey && e.key === 'z') {
|
if (e.ctrlKey && e.key === 'z') {
|
||||||
Analytics.undoGenerator(gen.id, (model?.historyIndex ?? 1) - 1, 'hotkey')
|
Analytics.undoGenerator(gen.id, model?.historyIndex ?? 1, 'hotkey')
|
||||||
model?.undo()
|
model?.undo()
|
||||||
} else if (e.ctrlKey && e.key === 'y') {
|
} else if (e.ctrlKey && e.key === 'y') {
|
||||||
Analytics.redoGenerator(gen.id, (model?.historyIndex ?? 1) + 1, 'hotkey')
|
Analytics.redoGenerator(gen.id, model?.historyIndex ?? 1, 'hotkey')
|
||||||
model?.redo()
|
model?.redo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user