Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: snapshot store to diff #3155

Open
wants to merge 4 commits into
base: v4.8.14-dev
Choose a base branch
from

Conversation

newfish-cmyk
Copy link
Collaborator

No description provided.

structuredClone(initialAppForm),
savedSnapshot?.diff
) as AppSimpleEditFormType;
const val = compareSimpleAppSnapshot(pastState, appForm);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接看,diff 是不是空的,应该就能知道了吧?不需要再比一次。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

保存的diff是和initialAppForm比的,这里应该得判断pastState和appForm的diff

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialAppForm 不就是记录开始编辑的状态么?这里计算的是,是否保存,就是指,跟最初状态比。

@c121914yu
Copy link
Collaborator

patch 方法封装起来,直接传入 diff 和 initState 即可获取最后结果。不要写这么复杂。


setPast((past) => [
{
appForm,
diff,
title: title || formatTime2YMDHMS(new Date()),
isSaved
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里,是不是得,始终保留第一条

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants