Skip to content

Commit

Permalink
Merge branch 'rm/363138' into 'master'
Browse files Browse the repository at this point in the history
restore custom pagination in get all groups call

See merge request kchat/webapp!938
  • Loading branch information
antonbuks committed Oct 3, 2024
2 parents 543be0b + 6d3a87e commit b11c56f
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions webapp/channels/src/packages/mattermost-redux/src/actions/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,42 @@ export function getGroup(id: string, includeMemberCount = false) {
});
}

export function getGroups(opts: GetGroupsParams) {
return bindClientFunc({
clientFunc: async (opts) => {
const result = await Client4.getGroups(opts);
return result;
},
onSuccess: [GroupTypes.RECEIVED_GROUPS],
params: [
opts,
],
});
export function getGroups(opts: GetGroupsParams): ActionFuncAsync {
// return bindClientFunc({
// clientFunc: async (opts) => {
// const result = await Client4.getGroups(opts);
// return result;
// },
// onSuccess: [GroupTypes.RECEIVED_GROUPS],
// params: [
// opts,
// ],
// });
// Infomaniak custom with pagination
return async (dispatch) => {
let groups: Group[] = [];
let currentFetch: Group[] = [];

try {
// eslint-disable-next-line no-constant-condition
while (true) {
// eslint-disable-next-line no-await-in-loop
currentFetch = await Client4.getGroups(opts);
groups = groups.concat(currentFetch);
if (!opts.per_page || currentFetch.length < opts.per_page) {
break;
}
opts.page += 1;
}
dispatch({
type: GroupTypes.RECEIVED_GROUPS,
data: groups,
});
} catch (error) {
dispatch(logError(error));
}
return {data: groups};
};
}

export function getGroupsNotAssociatedToTeam(teamID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, source = GroupSource.Ldap) {
Expand Down

0 comments on commit b11c56f

Please sign in to comment.