Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/actions/settings.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { Action } from 'redux';

import { ISettings, TSettings } from '../reducers/settings';
import { TSettingsState, TSupportedSettings, TSettingsValues } from '../reducers/settings';
import { SETTINGS } from './actionsTypes';

interface IAddSettings extends Action {
payload: ISettings;
payload: TSettingsState;
}

interface IUpdateSettings extends Action {
payload: { id: string; value: TSettings };
payload: { id: TSupportedSettings; value: TSettingsValues };
}

export type IActionSettings = IAddSettings & IUpdateSettings;

export function addSettings(settings: ISettings): IAddSettings {
export function addSettings(settings: TSettingsState): IAddSettings {
return {
type: SETTINGS.ADD,
payload: settings
};
}

export function updateSettings(id: string, value: TSettings): IUpdateSettings {
export function updateSettings(id: TSupportedSettings, value: TSettingsValues): IUpdateSettings {
return {
type: SETTINGS.UPDATE,
payload: { id, value }
Expand Down
2 changes: 1 addition & 1 deletion app/constants/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,4 @@ export default {
Canned_Responses_Enable: {
type: 'valueAsBoolean'
}
};
} as const;
5 changes: 3 additions & 2 deletions app/definitions/ISubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export enum SubscriptionType {
DIRECT = 'd',
CHANNEL = 'c',
OMNICHANNEL = 'l',
E2E = 'e2e',
E2E = 'e2e', // FIXME: this is not a type of subscription
THREAD = 'thread' // FIXME: this is not a type of subscription
}

Expand All @@ -28,7 +28,7 @@ export interface ISubscription {
_id: string; // _id belongs watermelonDB
id: string; // id from server
f: boolean;
t: SubscriptionType;
t: string; // TODO: we need to review this type later
ts: Date;
ls: Date;
name: string;
Expand Down Expand Up @@ -71,6 +71,7 @@ export interface ISubscription {
usernames?: string[];
visitor?: IVisitor;
departmentId?: string;
status?: string;
servedBy?: IServedBy;
livechatData?: any;
tags?: string[];
Expand Down
1 change: 1 addition & 0 deletions app/definitions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IBaseScreen<T extends Record<string, object | undefined>, S ext
route: RouteProp<T, S>;
dispatch: Dispatch;
theme: string;
isMasterDetail: boolean;
}

export * from './redux';
Expand Down
4 changes: 2 additions & 2 deletions app/definitions/redux/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import { IInviteLinks } from '../../reducers/inviteLinks';
import { IRoles } from '../../reducers/roles';
import { ISelectedUsers } from '../../reducers/selectedUsers';
import { IServer } from '../../reducers/server';
import { ISettings } from '../../reducers/settings';
import { TSettingsState } from '../../reducers/settings';
import { IShare } from '../../reducers/share';
import { IPermissionsState } from '../../reducers/permissions';
import { IEnterpriseModules } from '../../reducers/enterpriseModules';

export interface IApplicationState {
settings: ISettings;
settings: TSettingsState;
login: any;
meteor: IConnect;
server: IServer;
Expand Down
2 changes: 1 addition & 1 deletion app/lib/encryption/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const E2E_BANNER_TYPE = {
REQUEST_PASSWORD: 'REQUEST_PASSWORD',
SAVE_PASSWORD: 'SAVE_PASSWORD'
};
export const E2E_ROOM_TYPES = {
export const E2E_ROOM_TYPES: Record<string, string> = {
d: 'd',
p: 'p'
};
2 changes: 1 addition & 1 deletion app/lib/rocketchat/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ const RocketChat = {
}
const autoTranslatePermission = reduxStore.getState().permissions['auto-translate'];
const userRoles = reduxStore.getState().login?.user?.roles ?? [];
return autoTranslatePermission?.some(role => userRoles.includes(role));
return autoTranslatePermission?.some(role => userRoles.includes(role)) ?? false;
} catch (e) {
log(e);
return false;
Expand Down
2 changes: 1 addition & 1 deletion app/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const methods = {
};

export const compareServerVersion = (
currentServerVersion: string,
currentServerVersion: string | null,
method: keyof typeof methods,
versionToCompare: string
): boolean =>
Expand Down
8 changes: 6 additions & 2 deletions app/reducers/settings.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { addSettings, clearSettings, updateSettings } from '../actions/settings';
import { mockedStore } from './mockedStore';
import { initialState } from './settings';
import { initialState, TSettingsState } from './settings';

describe('test settings reducer', () => {
it('should return initial state', () => {
const state = mockedStore.getState().settings;
expect(state).toEqual(initialState);
});

const settings = { API_Use_REST_For_DDP_Calls: true, FileUpload_MaxFileSize: 600857600, Jitsi_URL_Room_Prefix: 'RocketChat' };
const settings: TSettingsState = {
API_Use_REST_For_DDP_Calls: true,
FileUpload_MaxFileSize: 600857600,
Jitsi_URL_Room_Prefix: 'RocketChat'
};

it('should return modified store after call addSettings action', () => {
mockedStore.dispatch(addSettings(settings));
Expand Down
12 changes: 8 additions & 4 deletions app/reducers/settings.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { IActionSettings } from '../actions/settings';
import { SETTINGS } from '../actions/actionsTypes';
import settings from '../constants/settings';

export type TSettings = string | number | boolean;
export type TSupportedSettings = keyof typeof settings;
export type TSettingsValues = string | number | boolean;

export type ISettings = Record<string, TSettings>;
export type TSettingsState = {
[K in TSupportedSettings]?: TSettingsValues;
};

export const initialState: ISettings = {};
export const initialState: TSettingsState = {};

export default (state = initialState, action: IActionSettings): ISettings => {
export default (state = initialState, action: IActionSettings): TSettingsState => {
switch (action.type) {
case SETTINGS.ADD:
return {
Expand Down
41 changes: 22 additions & 19 deletions app/stacks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,37 @@ import { ICannedResponse } from '../definitions/ICannedResponse';

export type ChatsStackParamList = {
RoomsListView: undefined;
RoomView: {
rid: string;
t: SubscriptionType;
tmid?: string;
message?: string;
name?: string;
fname?: string;
prid?: string;
room?: ISubscription;
jumpToMessageId?: string;
jumpToThreadId?: string;
roomUserId?: string;
};
RoomView:
| {
rid: string;
t: SubscriptionType;
tmid?: string;
message?: string;
name?: string;
fname?: string;
prid?: string;
room?: ISubscription;
jumpToMessageId?: string;
jumpToThreadId?: string;
roomUserId?: string;
usedCannedResponse?: string;
}
| undefined; // Navigates back to RoomView already on stack
RoomActionsView: {
room: ISubscription;
room: TSubscriptionModel;
member: any;
rid: string;
t: SubscriptionType;
joined: boolean;
};
SelectListView: {
data: IRoom[];
data?: IRoom[];
title: string;
infoText: string;
infoText?: string;
nextAction: (selected: string[]) => void;
showAlert: () => void;
isSearch: boolean;
onSearch: (text: string) => Partial<IRoom[]>;
showAlert?: () => void;
isSearch?: boolean;
onSearch?: (text: string) => Promise<Partial<IRoom[]> | any>;
isRadio?: boolean;
};
RoomInfoView: {
Expand Down
2 changes: 1 addition & 1 deletion app/views/CannedResponseDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const CannedResponseDetail = ({ navigation, route }: ICannedResponseDetailProps)
t: room.t,
fname: name
}),
t: room.t,
t: room.t as any,
roomUserId: RocketChat.getUidDirectMessage(room),
usedCannedResponse: item.text
};
Expand Down
2 changes: 1 addition & 1 deletion app/views/CannedResponsesListView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const CannedResponsesListView = ({ navigation, route }: ICannedResponsesListView
t: room.t,
fname: name
}),
t: room.t,
t: room.t as any,
roomUserId: RocketChat.getUidDirectMessage(room),
usedCannedResponse: item.text
};
Expand Down
Loading