chore: update definitions

This commit is contained in:
GleidsonDaniel 2021-12-29 13:19:48 -03:00
parent 48e4640bee
commit 0cf9765f86
6 changed files with 15 additions and 15 deletions

View File

@ -7,22 +7,22 @@ type TUser = {
user: ISelectedUser; user: ISelectedUser;
}; };
type IAction = Action & TUser; type TAction = Action & TUser;
interface ISetLoading extends Action { interface ISetLoading extends Action {
loading: boolean; loading: boolean;
} }
export type TActionSelectedUsers = IAction & ISetLoading; export type TActionSelectedUsers = TAction & ISetLoading;
export function addUser(user: ISelectedUser): IAction { export function addUser(user: ISelectedUser): TAction {
return { return {
type: types.SELECTED_USERS.ADD_USER, type: types.SELECTED_USERS.ADD_USER,
user user
}; };
} }
export function removeUser(user: ISelectedUser): IAction { export function removeUser(user: ISelectedUser): TAction {
return { return {
type: types.SELECTED_USERS.REMOVE_USER, type: types.SELECTED_USERS.REMOVE_USER,
user user

View File

@ -1,8 +1,8 @@
import { StackNavigationProp } from '@react-navigation/stack'; import { StackNavigationProp } from '@react-navigation/stack';
import { Dispatch } from 'redux'; import { Dispatch } from 'redux';
export interface BaseScreen { export interface IBaseScreen<T extends Record<string, object | undefined>, S extends string> {
navigation: StackNavigationProp<any>; navigation: StackNavigationProp<T, S>;
dispatch: Dispatch; dispatch: Dispatch;
theme: string; theme: string;
} }

View File

@ -4,7 +4,7 @@ import { TActionActiveUsers } from '../../actions/activeUsers';
import { IActiveUsers } from '../../reducers/activeUsers'; import { IActiveUsers } from '../../reducers/activeUsers';
import { ISelectedUsers } from '../../reducers/selectedUsers'; import { ISelectedUsers } from '../../reducers/selectedUsers';
export interface ApplicationState { export interface IApplicationState {
settings: any; settings: any;
login: any; login: any;
meteor: any; meteor: any;
@ -28,4 +28,4 @@ export interface ApplicationState {
roles: any; roles: any;
} }
export type ApplicationActions = TActionActiveUsers & TActionSelectedUsers; export type TApplicationActions = TActionActiveUsers & TActionSelectedUsers;

View File

@ -1,4 +1,4 @@
import { ApplicationActions } from '../definitions'; import { TApplicationActions } from '../definitions';
import { SET_ACTIVE_USERS } from '../actions/actionsTypes'; import { SET_ACTIVE_USERS } from '../actions/actionsTypes';
type TUserStatus = 'online' | 'offline'; type TUserStatus = 'online' | 'offline';
@ -13,7 +13,7 @@ export interface IActiveUsers {
export const initialState: IActiveUsers = {}; export const initialState: IActiveUsers = {};
export default function activeUsers(state = initialState, action: ApplicationActions): IActiveUsers { export default function activeUsers(state = initialState, action: TApplicationActions): IActiveUsers {
switch (action.type) { switch (action.type) {
case SET_ACTIVE_USERS: case SET_ACTIVE_USERS:
return { return {

View File

@ -1,4 +1,4 @@
import { ApplicationActions } from '../definitions'; import { TApplicationActions } from '../definitions';
import { SELECTED_USERS } from '../actions/actionsTypes'; import { SELECTED_USERS } from '../actions/actionsTypes';
export interface ISelectedUser { export interface ISelectedUser {
@ -20,7 +20,7 @@ export const initialState: ISelectedUsers = {
loading: false loading: false
}; };
export default function (state = initialState, action: ApplicationActions): ISelectedUsers { export default function (state = initialState, action: TApplicationActions): ISelectedUsers {
switch (action.type) { switch (action.type) {
case SELECTED_USERS.ADD_USER: case SELECTED_USERS.ADD_USER:
return { return {

View File

@ -14,7 +14,7 @@ import Loading from '../containers/Loading';
import SafeAreaView from '../containers/SafeAreaView'; import SafeAreaView from '../containers/SafeAreaView';
import SearchBox from '../containers/SearchBox'; import SearchBox from '../containers/SearchBox';
import StatusBar from '../containers/StatusBar'; import StatusBar from '../containers/StatusBar';
import { ApplicationState, BaseScreen } from '../definitions'; import { IApplicationState, IBaseScreen } from '../definitions';
import I18n from '../i18n'; import I18n from '../i18n';
import database from '../lib/database'; import database from '../lib/database';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';
@ -36,7 +36,7 @@ interface ISelectedUsersViewState {
chats: ISelectedUser[]; chats: ISelectedUser[];
} }
interface ISelectedUsersViewProps extends BaseScreen { interface ISelectedUsersViewProps extends IBaseScreen {
route: RouteProp<ChatsStackParamList, 'SelectedUsersView'>; route: RouteProp<ChatsStackParamList, 'SelectedUsersView'>;
// REDUX STATE // REDUX STATE
users: ISelectedUser[]; users: ISelectedUser[];
@ -296,7 +296,7 @@ class SelectedUsersView extends React.Component<ISelectedUsersViewProps, ISelect
}; };
} }
const mapStateToProps = (state: ApplicationState) => ({ const mapStateToProps = (state: IApplicationState) => ({
baseUrl: state.server.server, baseUrl: state.server.server,
users: state.selectedUsers.users, users: state.selectedUsers.users,
loading: state.selectedUsers.loading, loading: state.selectedUsers.loading,