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

Fix: content overwritten caused by diff merge on mobile platforms #9856

Merged
merged 2 commits into from Jul 14, 2023

Conversation

andelf
Copy link
Collaborator

@andelf andelf commented Jul 13, 2023

Root Cause:

On mobile platforms, DB is not persisted if the app goes inactive or gets killed. So DB(datascript transit files) will lose sync with the disk files if the App is closed by system UI or launcher.
This is very different from the Desktop version, where transit files are saved when closing-app/switching-graph.

(state/settings-open?)
(state/close-settings!)

(state/modal-opened?)
(state/close-modal!)

(state/get-left-sidebar-open?)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Minor fix for Android:
Settings should be closed before the left-sidebar.

@@ -1655,7 +1655,7 @@
(p/catch (fn [_] nil)))
current-content (or current-content "")
incoming-content (fs/read-file repo-dir incoming-file)
merged-content (diff-merge/three-way-merge current-content current-content incoming-content format)]
merged-content (diff-merge/three-way-merge "" incoming-content current-content format)]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Use empty content as the base.

@@ -103,7 +104,8 @@
(when (state/get-current-repo)
(let [is-active? (.-isActive state)]
(when-not is-active?
(editor-handler/save-current-block!))
(editor-handler/save-current-block!)
(repo-handler/persist-db!))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The primary fix is here.

Copy link
Collaborator

@cnrpman cnrpman left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@tiensonqin tiensonqin left a comment

Choose a reason for hiding this comment

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

LGTM

@tiensonqin tiensonqin force-pushed the fix/diff-merge-content-overwrite branch from 19358f0 to 549a44b Compare July 14, 2023 03:42
@tiensonqin tiensonqin merged commit 0368dec into master Jul 14, 2023
6 checks passed
@tiensonqin tiensonqin deleted the fix/diff-merge-content-overwrite branch July 14, 2023 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants