Skip to content

Commit 047660f

Browse files
fix: remove getAvatarSuggestion deprecated method (#6948)
* chore: type of getAvatarSuggestion * chore: add getAvatarSuggestion endpoint and backward compatibility * chore: format code and fix lint issues [skip ci] --------- Co-authored-by: OtavioStasiak <OtavioStasiak@users.noreply.github.com>
1 parent d2aa920 commit 047660f

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

app/definitions/rest/v1/users.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type IProfileParams } from '../../IProfile';
1+
import { type IAvatarSuggestion, type IProfileParams } from '../../IProfile';
22
import type { ITeam } from '../../ITeam';
33
import type { IUser, INotificationPreferences, IUserPreferences, IUserRegistered } from '../../IUser';
44

@@ -48,6 +48,12 @@ export type UsersEndpoints = {
4848
'users.getUsernameSuggestion': {
4949
GET: () => { result: string };
5050
};
51+
'users.getAvatarSuggestion': {
52+
GET: () => {
53+
suggestions: { [service: string]: IAvatarSuggestion };
54+
success: boolean;
55+
};
56+
};
5157
'users.resetAvatar': {
5258
POST: (params: { userId: string }) => {};
5359
};

app/lib/services/restApi.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,21 @@ export const getRoomRoles = (
677677
// RC 0.65.0
678678
sdk.get(`${roomTypeToApiType(type)}.roles`, { roomId });
679679

680-
export const getAvatarSuggestion = (): Promise<{ [service: string]: IAvatarSuggestion }> =>
680+
export const getAvatarSuggestion = async (): Promise<{ [service: string]: IAvatarSuggestion }> => {
681+
const serverVersion = reduxStore.getState().server.version;
682+
683+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '5.4.0')) {
684+
// RC 5.4.0
685+
const result = await sdk.get('users.getAvatarSuggestion');
686+
if (result.success && 'suggestions' in result) {
687+
return result.suggestions;
688+
}
689+
return {};
690+
}
691+
681692
// RC 0.51.0
682-
sdk.methodCallWrapper('getAvatarSuggestion');
693+
return sdk.methodCallWrapper('getAvatarSuggestion');
694+
};
683695

684696
export const resetAvatar = (userId: string) =>
685697
// RC 0.55.0

0 commit comments

Comments
 (0)