Skip to content

Commit f3f6a51

Browse files
committed
#3296 libgit2: show message if there are no versions
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent eb2026e commit f3f6a51

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
- Allow decrypting of the note text in the version dialog if the note was decrypted
66
in the note edit panel (for [#3342](https://github.com/pbek/QOwnNotes/issues/3342))
77
- In addition, when doing git versioning with libgit2 support also the diff will be decrypted
8+
- When viewing note version with enabled libgit2 support, now a message box will be shown
9+
that there are no versions if there are none (for [#3296](https://github.com/pbek/QOwnNotes/issues/3296))
810
- There now is a software repository for **Debian Linux 13.0**
911
- Please visit the [Debian installation page](https://www.qownnotes.org/installation/debian.html)
1012
for instructions (for [#3341](https://github.com/pbek/QOwnNotes/issues/3341))

src/mainwindow.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include <QGraphicsView>
6565
#include <QInputDialog>
6666
#include <QJSEngine>
67+
#include <QJSValueIterator>
6768
#include <QKeyEvent>
6869
#include <QListWidgetItem>
6970
#include <QMessageBox>
@@ -11270,6 +11271,30 @@ void MainWindow::on_actionShow_note_git_versions_triggered() {
1127011271
auto versions = Utils::Git::getNoteVersions(engine, currentNote, limit);
1127111272
showStatusBarMessage(tr("Done with gathering note versions from git"), QStringLiteral("🕒"),
1127211273
2000);
11274+
11275+
// Init the iterator for checking if there are versions
11276+
QJSValueIterator versionsCheckIterator(versions);
11277+
11278+
// QJSValueIterator may report hasNext as true even if there are no valid items,
11279+
// so we check for at least one valid version with a humanReadableTimestamp property.
11280+
bool hasValidVersion = false;
11281+
while (versionsCheckIterator.hasNext()) {
11282+
versionsCheckIterator.next();
11283+
QJSValue property =
11284+
versionsCheckIterator.value().property(QStringLiteral("humanReadableTimestamp"));
11285+
if (!property.isUndefined() && !property.toString().isEmpty()) {
11286+
hasValidVersion = true;
11287+
break;
11288+
}
11289+
}
11290+
11291+
if (!hasValidVersion) {
11292+
Utils::Gui::information(this, tr("No versions available"),
11293+
tr("No versions are available for this note."),
11294+
QStringLiteral("git-no-versions"));
11295+
return;
11296+
}
11297+
1127311298
auto *dialog = new VersionDialog(versions);
1127411299
dialog->setWindowTitle(
1127511300
tr("Latest %n git versions of note: %1", "", limit).arg(currentNote.getFileName()));

0 commit comments

Comments
 (0)