[gnome-sound-recorder] Recordings: sort by modified date
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder] Recordings: sort by modified date
- Date: Wed, 3 Jun 2020 16:35:39 +0000 (UTC)
commit b5080e551bd70c2ec587799112c25ac766a6363d
Author: Kavan Mevada <kavanmevada gmail com>
Date: Wed Jun 3 14:59:54 2020 +0530
Recordings: sort by modified date
fix #72
src/recordingList.js | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/recordingList.js b/src/recordingList.js
index 2708c39..664e1a1 100644
--- a/src/recordingList.js
+++ b/src/recordingList.js
@@ -30,7 +30,7 @@ var RecordingList = new GObject.registerClass(class RecordingList extends Gio.Li
break;
case Gio.FileMonitorEvent.MOVED_IN:
if (index === -1)
- this.insert(0, new Recording(file1));
+ this.sortedInsert(new Recording(file1));
break;
}
@@ -60,7 +60,7 @@ var RecordingList = new GObject.registerClass(class RecordingList extends Gio.Li
let path = GLib.build_filenamev([this._saveDir.get_path(), info.get_name()]);
let file = Gio.file_new_for_path(path);
let recording = new Recording(file);
- this.append(recording);
+ this.sortedInsert(recording);
});
} else {
this._enumerator.close(null);
@@ -76,4 +76,20 @@ var RecordingList = new GObject.registerClass(class RecordingList extends Gio.Li
}
return -1;
}
+
+ sortedInsert(recording) {
+ let added = false;
+
+ for (let i = 0; i < this.get_n_items(); i++) {
+ const curr = this.get_item(i);
+ if (curr.timeModified.difference(recording.timeModified) <= 0) {
+ this.insert(i, recording);
+ added = true;
+ break;
+ }
+ }
+
+ if (!added)
+ this.append(recording);
+ }
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]