Skip to content

Commit

Permalink
feat: implement order
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <vitor@php.rio>
  • Loading branch information
vitormattos authored and backportbot-libresign[bot] committed Nov 5, 2024
1 parent e812cdb commit 05cc0dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/store/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ export const useFilesStore = function(...args) {
loading: false,
filterActive: 'all',
canRequestSign: loadState('libresign', 'can_request_sign', false),
ordered: [],
}
},

actions: {
addFile(file) {
set(this.files, file.nodeId, file)
this.hydrateFile(file.nodeId)
this.ordered.push(file.nodeId)
},
selectFile(nodeId) {
this.selectedNodeId = nodeId ?? 0
Expand Down Expand Up @@ -229,6 +231,11 @@ export const useFilesStore = function(...args) {
}))
}
del(this.files, file.nodeId)

const index = this.ordered.indexOf(file.nodeId)
if (index > -1) {
this.ordered.splice(index, 1)
}
},
async getAllFiles(filter) {
if (!filter) filter = {}
Expand All @@ -250,11 +257,15 @@ export const useFilesStore = function(...args) {
}
const response = await axios.get(generateOcsUrl('/apps/libresign/api/v1/file/list'), { params: filter })
this.files = {}
this.ordered = []
response.data.ocs.data.data.forEach(file => {
this.addFile(file)
})
return this.files
},
filesSorted() {
return this.ordered.map(key => this.files[key])
},
filter(type) {
this.filterActive = type
if (type === 'pending') {
Expand Down
2 changes: 1 addition & 1 deletion src/views/FilesList/VirtualList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:class="userConfigStore.grid_view ? 'files-list__tbody--grid' : 'files-list__tbody--list'"
data-cy-files-list-tbody>
<component :is="dataComponent"
v-for="(item) in filesStore.files"
v-for="(item) in filesStore.filesSorted()"
:key="item.nodeId"
:source="item"
:loading="loading" />
Expand Down

0 comments on commit 05cc0dd

Please sign in to comment.