Skip to content

Commit dc153f2

Browse files
committed
fix(files_sharing): Sort by correct share attribute ("share with displayname")
There is no `title` attribute, so this causes an exception. Instead sort by the "share with" displayname which will be the user or group the node is shared to. Meaning this will also be the title of the share in the UI. If this is not available or there are multiple for the same, then sort by the custom label. If also this is not set sort by the creation time. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 1907eee commit dc153f2

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

apps/files_sharing/src/views/SharingTab.vue

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@
8282
</template>
8383

8484
<script>
85-
import { CollectionList } from 'nextcloud-vue-collections'
86-
import { generateOcsUrl } from '@nextcloud/router'
87-
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
8885
import axios from '@nextcloud/axios'
86+
import { orderBy } from '@nextcloud/files'
8987
import { loadState } from '@nextcloud/initial-state'
88+
import { generateOcsUrl } from '@nextcloud/router'
89+
import { CollectionList } from 'nextcloud-vue-collections'
90+
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
9091
9192
import Config from '../services/ConfigService.ts'
9293
import { shareWithTitle } from '../utils/SharedWithMe.js'
@@ -260,16 +261,18 @@ export default {
260261
*/
261262
processShares({ data }) {
262263
if (data.ocs && data.ocs.data && data.ocs.data.length > 0) {
263-
// create Share objects and sort by title in alphabetical order and then by creation time
264-
const shares = data.ocs.data
265-
.map(share => new Share(share))
266-
.sort((a, b) => {
267-
const localCompare = a.title.localeCompare(b.title)
268-
if (localCompare !== 0) {
269-
return localCompare
270-
}
271-
return b.createdTime - a.createdTime
272-
})
264+
const shares = orderBy(
265+
data.ocs.data.map(share => new Share(share)),
266+
[
267+
// First order by the "share with" label
268+
(share) => share.shareWithDisplayName,
269+
// Then by the label
270+
(share) => share.label,
271+
// And last resort order by createdTime
272+
(share) => share.createdTime,
273+
],
274+
)
275+
273276
this.linkShares = shares.filter(share => share.type === this.SHARE_TYPES.SHARE_TYPE_LINK || share.type === this.SHARE_TYPES.SHARE_TYPE_EMAIL)
274277
this.shares = shares.filter(share => share.type !== this.SHARE_TYPES.SHARE_TYPE_LINK && share.type !== this.SHARE_TYPES.SHARE_TYPE_EMAIL)
275278

0 commit comments

Comments
 (0)