DiffScreen: Respect the "Skip Uncommented" diff preference
The effect of this preference wasn't migrated from the old diff screen to the current one, and the prefernce hasn't been available in the diff preferences box, but the preference itself was migrated from ReviewDb to NoteDb (the Git backend). This change updates the diff screen header to respect this preference. Now that the side-by-side and the unified diff screens share the same code base, this feature is made available in both of them. Note that currently, the navigation links and keyboard shortcuts are not updated upon toggling the option in PreferencesBox: they are only updated when the preference is saved and the diff screen is reloaded. To support updating without refreshing, we will need to replace the KeyCommand in GlobalKey, which is of low priority and will be implemented in a future change. Bug: Issue 3446 Change-Id: Ia594703c9fe7580387d6efb5f5e1011e1ceb5f7d
This commit is contained in:
@@ -97,6 +97,7 @@ public class Header extends Composite {
|
||||
private boolean hasPrev;
|
||||
private boolean hasNext;
|
||||
private String nextPath;
|
||||
private JsArray<FileInfo> files;
|
||||
private PreferencesAction prefsAction;
|
||||
private ReviewedState reviewedState;
|
||||
|
||||
@@ -161,12 +162,11 @@ public class Header extends Composite {
|
||||
DiffApi.list(patchSetId, base, new GerritCallback<NativeMap<FileInfo>>() {
|
||||
@Override
|
||||
public void onSuccess(NativeMap<FileInfo> result) {
|
||||
JsArray<FileInfo> files = result.values();
|
||||
files = result.values();
|
||||
FileInfo.sortFileInfoByPath(files);
|
||||
fileNumber.setInnerText(
|
||||
Integer.toString(Natives.asList(files).indexOf(result.get(path)) + 1));
|
||||
fileCount.setInnerText(Integer.toString(files.length()));
|
||||
setupPrevNextFiles(files, findCurrentFileIndex(files));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -300,12 +300,18 @@ public class Header extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
void setupPrevNextFiles(JsArray<FileInfo> files, int currIndex) {
|
||||
private boolean shouldSkipFile(FileInfo curr, CommentsCollections comments) {
|
||||
return prefs.skipDeleted() && ChangeType.DELETED.matches(curr.status())
|
||||
|| prefs.skipUncommented() && !comments.hasCommentForPath(curr.path());
|
||||
}
|
||||
|
||||
void setupPrevNextFiles(CommentsCollections comments) {
|
||||
FileInfo prevInfo = null;
|
||||
FileInfo nextInfo = null;
|
||||
int currIndex = findCurrentFileIndex(files);
|
||||
for (int i = currIndex - 1; i >= 0; i--) {
|
||||
FileInfo curr = files.get(i);
|
||||
if (prefs.skipDeleted() && ChangeType.DELETED.matches(curr.status())) {
|
||||
if (shouldSkipFile(curr, comments)) {
|
||||
continue;
|
||||
} else {
|
||||
prevInfo = curr;
|
||||
@@ -314,7 +320,7 @@ public class Header extends Composite {
|
||||
}
|
||||
for (int i = currIndex + 1; i < files.length(); i++) {
|
||||
FileInfo curr = files.get(i);
|
||||
if (prefs.skipDeleted() && ChangeType.DELETED.matches(curr.status())) {
|
||||
if (shouldSkipFile(curr, comments)) {
|
||||
continue;
|
||||
} else {
|
||||
nextInfo = curr;
|
||||
|
||||
Reference in New Issue
Block a user