feat: show exact match first in sharing widget (#112)

pull/120/head
znerol 2021-01-25 18:39:35 +01:00 committed by GitHub
parent 10f9126d42
commit f2f9852bb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 6 deletions

View File

@ -75,6 +75,11 @@ export interface ShareWith {
users: ShareWithOption[];
groups: ShareWithOption[];
circles: ShareWithOption[];
exact: {
users: ShareWithOption[];
groups: ShareWithOption[];
circles: ShareWithOption[];
}
}
class Api {
@ -243,9 +248,14 @@ class Api {
});
return {
users: response.data.ocs.data.exact.users,
groups: response.data.ocs.data.exact.groups,
circles: response.data.ocs.data.exact.circles || [],
users: [],
groups: [],
circles: [],
exact: {
users: response.data.ocs.data.exact.users,
groups: response.data.ocs.data.exact.groups,
circles: response.data.ocs.data.exact.circles || [],
},
};
}
@ -264,9 +274,14 @@ class Api {
const data = response.data.ocs.data;
return {
users: [...data.users, ...data.exact.users],
groups: [...data.groups, ...data.exact.groups],
circles: [...(data.circles || []), ...(data.exact.circles || [])],
users: data.users,
groups: data.groups,
circles: data.circles || [],
exact: {
users: data.exact.users,
groups: data.exact.groups,
circles: data.exact.circles || [],
},
};
}
}

View File

@ -63,6 +63,9 @@ const ShareSelection: React.FC<Props> = (props) => {
function renderSearchResults(options: ShareWith|undefined) {
const results = options ? [
...options.exact.users.filter(user => !excluded.userIds.includes(user.value.shareWith)),
...options.exact.groups.filter(group => !excluded.groupIds.includes(group.value.shareWith)),
...options.exact.circles.filter(circle => !excluded.circleIds.includes(circle.value.shareWith)),
...options.users.filter(user => !excluded.userIds.includes(user.value.shareWith)),
...options.groups.filter(group => !excluded.groupIds.includes(group.value.shareWith)),
...options.circles.filter(circle => !excluded.circleIds.includes(circle.value.shareWith)),