Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion gui/default/syncthing/core/syncthingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2685,6 +2685,8 @@ angular.module('syncthing.core')
if (closed) {
resetRestoreVersions();
return;
} else if ($scope.sizeOf($scope.restoreVersions.versions) === '0') {
return;
}

$scope.restoreVersions.tree = $("#restoreTree").fancytree({
Expand All @@ -2701,7 +2703,7 @@ angular.module('syncthing.core')
indentation: 24,
},
strings: {
loading: $translate.instant("Loading..."),
loading: $translate.instant("Loading data..."),
loadError: $translate.instant("Failed to load file versions."),
noData: $translate.instant("There are no file versions to restore.")
},
Expand Down
12 changes: 7 additions & 5 deletions gui/default/syncthing/folder/restoreVersionsModalView.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<modal id="restoreVersions" status="default" icon="fas fa-undo" heading="{{'Restore Versions' | translate}} ({{folderLabel(restoreVersions.folder)}})" large="yes" closeable="yes">
<div class="modal-body">
<span translate ng-if="!restoreVersions.versions && !restoreVersions.errors">Loading data...</span>
<div ng-if="restoreVersions.versions">
<div ng-if="restoreVersions.versions && !restoreVersions.errors">
<div id="restoreTree-container">
<table id="restoreTree">
<tbody>
<tr>
<td></td>
<td>
<span ng-if="sizeOf(restoreVersions.versions) > 0" translate>Loading data...</span>
<span ng-if="sizeOf(restoreVersions.versions) == 0" translate>There are no file versions to restore.</span>
</td>
Comment on lines +8 to +11

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume this exists for the time until fancytree is initialised, isn't it? What's the point of the conditional, instead of just always showing "loading data" until fancytree is ready?

@tomasz1986 tomasz1986 Jan 15, 2023 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good question, and the code was remnants from the previous iteration, however I've now added yet another similar sizeOf check in the controller, so that the tree code doesn't run at all when there are no versions. This way, the window loads faster, there is no 1970 year stuck in the disabled date filter, and the two conditionals are actually required again (because without the tree code running, the existing table isn't replaced with the tree table).

I hope the explanation is clear… What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yep makes sense. I don't think I'll remember/be able to figure it out if I ever stumble over this again though, but it wasn't any better before so 🤷

<td></td>
</tr>
</tbody>
Expand All @@ -17,13 +19,13 @@
<div class="col-md-6">
<div class="form-group">
<label for="restoreVersionSearch"><span translate>Filter by name</span>:&nbsp</label>
<input id="restoreVersionSearch" class="form-control" type="text" ng-model="restoreVersions.filters.text">
<input id="restoreVersionSearch" class="form-control" type="text" ng-model="restoreVersions.filters.text" ng-disabled="sizeOf(restoreVersions.versions) == 0">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="restoreVersionDate"><span translate>Filter by date</span>:&nbsp</label>
<input id="restoreVersionDateRange" class="form-control">
<input id="restoreVersionDateRange" class="form-control" ng-disabled="sizeOf(restoreVersions.versions) == 0">
</div>
</div>
</div>
Expand Down