Skip to content

Commit

Permalink
Correctly update file after sharing. NC PR: nextcloud#11775
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder-tsys committed Oct 18, 2023
1 parent 154796b commit 91efa3c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation ope
}

if (fileListFragment instanceof OCFileListFragment && file != null) {
((OCFileListFragment) fileListFragment).updateOCFile(file);
((OCFileListFragment) fileListFragment).getAdapter().replaceFile(file);
}
} else {
// Detect Failure (403) --> maybe needs password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,14 @@ public void setData(List<Object> objects,
new Handler(Looper.getMainLooper()).post(this::notifyDataSetChanged);
}

@SuppressLint("NotifyDataSetChanged")
public void replaceFile(OCFile file) {
mFiles.remove(file);
mFiles.add(file);
mFiles = sortOrder.sortCloudFiles(mFiles);
notifyDataSetChanged();
}

private void parseShares(List<Object> objects) {
List<OCShare> shares = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1370,12 +1370,6 @@ public void listDirectory(OCFile directory, OCFile file, boolean onlyOnDevice, b
}
}

public void updateOCFile(OCFile file) {
List<OCFile> mFiles = mAdapter.getFiles();
mFiles.set(mFiles.indexOf(file), file);
mAdapter.notifyItemChanged(file);
}

private void updateLayout() {
// decide grid vs list view
if (isGridViewPreferred(mFile)) {
Expand Down

0 comments on commit 91efa3c

Please sign in to comment.