Skip to content

Commit

Permalink
Fix File diff state is not updated after copy confirmation 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pertsevpv committed Nov 14, 2024
1 parent 0e3dbd5 commit 60c053f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ private void update(JsArray<JSObject> jsResult) {
}

private void onDiffApplied(JsArray<JSObject> jsResult) {
LoggingJs.info("RemoteFolderDiffWindow.onDiffApplied");
var msg = BackendMessage.deserialize(jsResult);
rootModel.update(msg.root);
updateNodes(leftRoot, rightRoot, rootModel);
Expand Down Expand Up @@ -589,6 +590,7 @@ private void sendApplyDiff(FolderDiffModel model, boolean left) {
result.set(1, JsCast.jsInts(left ? 0 : 1));
result.push(DiffModelChannelUpdater.APPLY_DIFF_ARRAY);
channel.sendMessage(result);
LoggingJs.info("RemoteFolderDiffWindow.sendApplyDiff");
}

void fileDiffMade(FolderDiffModel dModel, boolean left, Model model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,23 @@ public ItemFolderDiffModel parent() {
public ItemFolderDiffModel findNeedUpdate(Deque<ItemFolderDiffModel> paths) {
if (parent == null) return this;
int diffType = getDiffType();
if ((diffType == DiffTypes.DEFAULT || diffType == DiffTypes.EDITED) && countItems() < 2) {
if (this.isFile() || (diffType == DiffTypes.DEFAULT || diffType == DiffTypes.EDITED) && countItems() < 2) {
paths.addFirst(this);
return parent().findNeedUpdate(paths);
}
return this;
}

public void setItems(FsItem left, FsItem right) {
if (!path.equals(left.getName()) || !path.equals(right.getName()))
System.out.println("Set items: " + left.getName() + " & " + right.getName() + " to " + path);
items[0] = left;
items[1] = right;
}

public void setItem(FsItem item) {
if (!path.equals(item.getName()))
System.out.println("Set item: " + item.getName() + " to " + path);
if (isLeftOnly()) items[0] = item;
else if (isRightOnly()) items[1] = item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public void applyDiff(int[] path, boolean left) {
lastFrontendMessage.collectPath(path, pathWriter, root, left);

Runnable updateModel = () -> {
LoggingJs.info("RemoteCollector.applyDiff.updateModel");
if (isDeleteDiff) {
var node = lastFrontendMessage.findNode(path);
var parentNode = lastFrontendMessage.findParentNode(path);
Expand Down Expand Up @@ -143,7 +144,8 @@ private void updateModelItems(ItemFolderDiffModel model, boolean left) {
sb.append(path);
st += path.length();
}

LoggingJs.info("Upd Model: " + updModel.path);
LoggingJs.info("Send reread");
executor.sendToWorker(true,
(res) -> updateNode(updModel, !left, updModelPath, res),
DiffUtils.REREAD_FOLDER,
Expand All @@ -152,6 +154,7 @@ private void updateModelItems(ItemFolderDiffModel model, boolean left) {
}

private void updateNode(ItemFolderDiffModel updModel, boolean left, Deque<ItemFolderDiffModel> updModelPath, Object[] result) {
LoggingJs.info("RemoteCollector.updateNode");
int[] ints = ((ArrayView) result[0]).ints();
ArrayReader reader = new ArrayReader(ints);
Deque<FsItem> items = new LinkedList<>();
Expand Down

0 comments on commit 60c053f

Please sign in to comment.