summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-04-12 16:45:27 +0100
committerPhil Hughes <me@iamphill.com>2018-04-16 09:49:00 +0100
commitcacc8f40a59f3b40aa9de853a84c0688a8f6f8e4 (patch)
treea6e9a0aa2df0345f66a1a6685c3b67a1e6796ee8
parente51fde9a08638f127ffbaf53e174f1aa994e325d (diff)
downloadgitlab-ce-cacc8f40a59f3b40aa9de853a84c0688a8f6f8e4.tar.gz
fixes the sort to correctly order the array
-rw-r--r--app/assets/javascripts/ide/components/file_finder/index.vue3
-rw-r--r--app/assets/javascripts/ide/stores/getters.js16
2 files changed, 9 insertions, 10 deletions
diff --git a/app/assets/javascripts/ide/components/file_finder/index.vue b/app/assets/javascripts/ide/components/file_finder/index.vue
index 5049588e0a4..d7bba6252e8 100644
--- a/app/assets/javascripts/ide/components/file_finder/index.vue
+++ b/app/assets/javascripts/ide/components/file_finder/index.vue
@@ -24,7 +24,8 @@ export default {
filteredBlobs() {
const searchText = this.searchText.trim();
- if (searchText === '') return this.allBlobs.slice(0, MAX_RESULTS);
+ if (searchText === '')
+ return this.allBlobs.sort((a, b) => b.lastOpenedAt - a.lastOpenedAt).slice(0, MAX_RESULTS);
return fuzzaldrinPlus.filter(this.allBlobs, searchText, {
key: 'path',
diff --git a/app/assets/javascripts/ide/stores/getters.js b/app/assets/javascripts/ide/stores/getters.js
index f2cd8551a0a..07f7e73d8e9 100644
--- a/app/assets/javascripts/ide/stores/getters.js
+++ b/app/assets/javascripts/ide/stores/getters.js
@@ -37,14 +37,12 @@ export const hasChanges = state => !!state.changedFiles.length;
export const hasMergeRequest = state => !!state.currentMergeRequestId;
export const allBlobs = state =>
- Object.keys(state.entries)
- .reduce((acc, key) => {
- const entry = state.entries[key];
+ Object.keys(state.entries).reduce((acc, key) => {
+ const entry = state.entries[key];
- if (entry.type === 'blob') {
- acc.push(entry);
- }
+ if (entry.type === 'blob') {
+ acc.push(entry);
+ }
- return acc;
- }, [])
- .sort((a, b) => b.lastOpenedAt > a.lastOpenedAt);
+ return acc;
+ }, []);