From 014a57e54174ce9a8f2c55beafad2dd8d1c6a9d0 Mon Sep 17 00:00:00 2001
From: John Molakvoæ <skjnldsv@protonmail.com>
Date: Tue, 4 Apr 2023 08:10:43 +0200
Subject: fix: improved preview handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
---
 apps/files/src/components/FilesListHeader.vue | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

(limited to 'apps/files/src/components/FilesListHeader.vue')

diff --git a/apps/files/src/components/FilesListHeader.vue b/apps/files/src/components/FilesListHeader.vue
index 184ca7aa30e..f0af8c531dc 100644
--- a/apps/files/src/components/FilesListHeader.vue
+++ b/apps/files/src/components/FilesListHeader.vue
@@ -88,6 +88,12 @@ export default Vue.extend({
 		FilesListHeaderActions,
 	},
 
+	provide() {
+		return {
+			toggleSortBy: this.toggleSortBy,
+		}
+	},
+
 	props: {
 		isSizeAvailable: {
 			type: Boolean,
@@ -186,6 +192,16 @@ export default Vue.extend({
 			}
 		},
 
+		toggleSortBy(key) {
+			// If we're already sorting by this key, flip the direction
+			if (this.sortingMode === key) {
+				this.sortingStore.toggleSortingDirection(this.currentView.id)
+				return
+			}
+			// else sort ASC by this new key
+			this.sortingStore.setSortingBy(key, this.currentView.id)
+		},
+
 		t: translate,
 	},
 })
-- 
cgit v1.2.3

