Chore: Migrate REST API - saveUserProfile to Typescript (#3863)

* Chore: Migrate REST API - saveUserProfile to Typescript

* minor tweak
This commit is contained in:
Reinaldo Neto 2022-03-09 15:10:36 -03:00 committed by GitHub
parent b962925121
commit 60ecbe284c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import { StackNavigationProp } from '@react-navigation/stack'; import { StackNavigationProp } from '@react-navigation/stack';
import React from 'react'; import React from 'react';
import { ProfileStackParamList } from '../../stacks/types'; import { ProfileStackParamList } from '../stacks/types';
export interface IUser { export interface IUser {
id: string; id: string;

View File

@ -1,3 +1,4 @@
import { IParams } from '../../IProfileViewInterfaces';
import type { ITeam } from '../../ITeam'; import type { ITeam } from '../../ITeam';
import type { IUser } from '../../IUser'; import type { IUser } from '../../IUser';
import { INotificationPreferences, IUserPreferences, IUserRegistered } from '../../IUser'; import { INotificationPreferences, IUserPreferences, IUserRegistered } from '../../IUser';
@ -37,4 +38,9 @@ export type UsersEndpoints = {
'users.setStatus': { 'users.setStatus': {
POST: (params: { status: string; message: string }) => {}; POST: (params: { status: string; message: string }) => {};
}; };
'users.updateOwnBasicInfo': {
POST: (params: { data: IParams | Pick<IParams, 'username'>; customFields?: { [key: string | number]: string } }) => {
user: IUser;
};
};
}; };

View File

@ -3,6 +3,7 @@ import { TEAM_TYPE } from '../../../definitions/ITeam';
import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType'; import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType';
import { SubscriptionType, INotificationPreferences, IRoomNotifications } from '../../../definitions'; import { SubscriptionType, INotificationPreferences, IRoomNotifications } from '../../../definitions';
import { ISpotlight } from '../../../definitions/ISpotlight'; import { ISpotlight } from '../../../definitions/ISpotlight';
import { IParams } from '../../../definitions/IProfileViewInterfaces';
export const createChannel = ({ export const createChannel = ({
name, name,
@ -545,10 +546,8 @@ export const saveRoomSettings = (
// RC 0.55.0 // RC 0.55.0
sdk.methodCallWrapper('saveRoomSettings', rid, params); sdk.methodCallWrapper('saveRoomSettings', rid, params);
export const saveUserProfile = (data: any, customFields?: any): any => export const saveUserProfile = (data: IParams | Pick<IParams, 'username'>, customFields?: { [key: string | number]: string }) =>
// RC 0.62.2 // RC 0.62.2
// TODO: missing definitions from server
// @ts-ignore
sdk.post('users.updateOwnBasicInfo', { data, customFields }); sdk.post('users.updateOwnBasicInfo', { data, customFields });
export const saveUserPreferences = (data: Partial<INotificationPreferences>) => export const saveUserPreferences = (data: Partial<INotificationPreferences>) =>

View File

@ -31,7 +31,15 @@ import { withTheme } from '../../theme';
import { getUserSelector } from '../../selectors/login'; import { getUserSelector } from '../../selectors/login';
import SafeAreaView from '../../containers/SafeAreaView'; import SafeAreaView from '../../containers/SafeAreaView';
import styles from './styles'; import styles from './styles';
import { IAvatar, IAvatarButton, INavigationOptions, IParams, IProfileViewProps, IProfileViewState, IUser } from './interfaces'; import {
IAvatar,
IAvatarButton,
INavigationOptions,
IParams,
IProfileViewProps,
IProfileViewState,
IUser
} from '../../definitions/IProfileViewInterfaces';
class ProfileView extends React.Component<IProfileViewProps, IProfileViewState> { class ProfileView extends React.Component<IProfileViewProps, IProfileViewState> {
private name: any; private name: any;

View File

@ -34,7 +34,7 @@ import log, { events, logEvent } from '../../utils/log';
import { MessageTypeValues } from '../../utils/messageTypes'; import { MessageTypeValues } from '../../utils/messageTypes';
import random from '../../utils/random'; import random from '../../utils/random';
import scrollPersistTaps from '../../utils/scrollPersistTaps'; import scrollPersistTaps from '../../utils/scrollPersistTaps';
import { IAvatar } from '../ProfileView/interfaces'; import { IAvatar } from '../../definitions/IProfileViewInterfaces';
import sharedStyles from '../Styles'; import sharedStyles from '../Styles';
import styles from './styles'; import styles from './styles';
import SwitchContainer from './SwitchContainer'; import SwitchContainer from './SwitchContainer';