Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bbcce41
base
diegolmello Oct 11, 2024
93b4d2b
Login with token
diegolmello Oct 11, 2024
9d91821
custom emojis
diegolmello Oct 14, 2024
8f7e4ae
sdk.current.rest.get
diegolmello Oct 14, 2024
4704620
getSettings
diegolmello Oct 14, 2024
4525063
Fixed some post
diegolmello Oct 14, 2024
9f8a4d8
rooms sub
diegolmello Oct 15, 2024
4098169
room sub
diegolmello Oct 15, 2024
5cdce98
Fix login with password
diegolmello Oct 15, 2024
c7365c3
_stream room
diegolmello Oct 15, 2024
414b0b7
_stream rooms
diegolmello Oct 15, 2024
577c2f4
cleanup
diegolmello Oct 15, 2024
221eaab
Fix more streams
diegolmello Oct 15, 2024
9567d48
user activity on older servers
diegolmello Oct 15, 2024
d3ab712
sdk.current?.rest.get -> sdk.get
diegolmello Oct 15, 2024
15098c2
disconnect
diegolmello Oct 16, 2024
7539cd9
Remove abort leftovers
diegolmello Oct 16, 2024
8cedb22
Merge branch 'develop' into chore.js-sdk
diegolmello Oct 16, 2024
6a9af7c
typo closed
diegolmello Oct 16, 2024
4de34a6
undefined roles on fetchUsersRoles
diegolmello Oct 17, 2024
d1bac25
Add a more clear comment to checkAndReopen behavior
diegolmello Oct 17, 2024
9dd251f
New SDK on remove server from servers list
diegolmello Oct 17, 2024
ad681fd
Use new sdk on get websocket info
diegolmello Oct 17, 2024
b6c2688
Remove isSsl
diegolmello Oct 17, 2024
b70eba5
Basic auth and user agent headers
diegolmello Oct 17, 2024
24e1be9
Merge branch 'develop' into chore.js-sdk
diegolmello Oct 21, 2024
2272fce
Use rest api on login and handle totp
diegolmello Oct 24, 2024
075123f
Remove old SDK
diegolmello Oct 24, 2024
e03745d
Fix most ts issues on sdk
diegolmello Oct 25, 2024
ca03db5
Fix methodCall result
diegolmello Oct 25, 2024
4b4244c
restapis...
diegolmello Oct 28, 2024
d16d979
Workaround to prevent white screen flash after splash
diegolmello Oct 28, 2024
d3b5f3c
Fixing types
diegolmello Oct 28, 2024
b062233
more ts fixes
diegolmello Oct 29, 2024
496910a
Tsssss
diegolmello Oct 29, 2024
407267a
Temp disable lint
diegolmello Nov 4, 2024
af75686
Merge branch 'develop' into chore.js-sdk
diegolmello Nov 4, 2024
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
22 changes: 11 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -387,21 +387,21 @@ jobs:
steps:
- checkout

- restore_cache: *restore-npm-cache-linux
# - restore_cache: *restore-npm-cache-linux

- run: *install-npm-modules
# - run: *install-npm-modules

- run:
name: Lint
command: |
yarn lint
# - run:
# name: Lint
# command: |
# yarn lint

- run:
name: Test
command: |
yarn test --runInBand
# - run:
# name: Test
# command: |
# yarn test --runInBand

- save_cache: *save-npm-cache-linux
# - save_cache: *save-npm-cache-linux

# Android builds
android-build-experimental:
Expand Down
4 changes: 2 additions & 2 deletions app/containers/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import { View } from 'react-native';
import FastImage from 'react-native-fast-image';
import Touchable from 'react-native-platform-touchable';
import { settings as RocketChatSettings } from '@rocket.chat/sdk';

import { getAvatarURL } from '../../lib/methods/helpers/getAvatarUrl';
import sdk from '../../lib/services/sdk';
import { SubscriptionType } from '../../definitions';
import Emoji from '../markdown/Emoji';
import { IAvatar } from './interfaces';
Expand Down Expand Up @@ -72,7 +72,7 @@ const Avatar = React.memo(
style={avatarStyle}
source={{
uri,
headers: RocketChatSettings.customHeaders,
headers: sdk.getHeaders(),
priority: FastImage.priority.high
}}
/>
Expand Down
29 changes: 14 additions & 15 deletions app/containers/MessageActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { IApplicationState, IEmoji, ILoggedUser, TAnyMessageModel, TSubscription
import { getPermalinkMessage, getQuoteMessageLink } from '../../lib/methods';
import { compareServerVersion, getRoomTitle, getUidDirectMessage, hasPermission } from '../../lib/methods/helpers';
import { Services } from '../../lib/services';
import sdk from '../../lib/services/sdk';

export interface IMessageActionsProps {
room: TSubscriptionModel;
Expand Down Expand Up @@ -217,19 +218,17 @@ const MessageActions = React.memo(
const { rid } = room;
try {
const db = database.active;
const result = await Services.markAsUnread({ messageId });
if (result.success) {
const subCollection = db.get('subscriptions');
const subRecord = await subCollection.find(rid);
await db.write(async () => {
try {
await subRecord.update(sub => (sub.lastOpen = ts as Date)); // TODO: reevaluate IMessage
} catch {
// do nothing
}
});
Navigation.navigate('RoomsListView');
}
await sdk.post('/v1/subscriptions.unread', { firstUnreadMessage: { _id: messageId } });
const subCollection = db.get('subscriptions');
const subRecord = await subCollection.find(rid);
await db.write(async () => {
try {
await subRecord.update(sub => (sub.lastOpen = ts as Date)); // TODO: reevaluate IMessage
} catch {
// do nothing
}
});
Navigation.navigate('RoomsListView');
} catch (e) {
logEvent(events.ROOM_MSG_ACTION_UNREAD_F);
log(e);
Expand Down Expand Up @@ -272,8 +271,8 @@ const MessageActions = React.memo(

const handleReplyInDM = async (message: TAnyMessageModel) => {
if (message?.u?.username) {
const result = await Services.createDirectMessage(message.u.username);
if (result.success) {
const result = await sdk.post('/v1/im.create', { username: message.u.username });
if (result) {
const { room } = result;
const params = {
rid: room.rid,
Expand Down
10 changes: 8 additions & 2 deletions app/containers/MessageComposer/MessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import { IEmoji } from '../../definitions';
import database from '../../lib/database';
import { sanitizeLikeString } from '../../lib/database/utils';
import { generateTriggerId } from '../../lib/methods';
import { Services } from '../../lib/services';
import log from '../../lib/methods/helpers/log';
import { prepareQuoteMessage } from './helpers';
import { RecordAudio } from './components/RecordAudio';
import { useKeyboardListener } from './hooks';
import { emitter } from '../../lib/methods/helpers/emitter';
import sdk from '../../lib/services/sdk';

const styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -139,7 +139,13 @@ export const MessageComposer = ({
const messageWithoutCommand = textFromInput.replace(/([^\s]+)/, '').trim();
const [{ appId }] = slashCommand;
const triggerId = generateTriggerId(appId);
await Services.runSlashCommand(command, rid, messageWithoutCommand, triggerId, tmid);
await sdk.post('/v1/commands.run', {
command,
roomId: rid,
params: messageWithoutCommand,
triggerId,
...(tmid && { tmid })
});
} catch (e) {
log(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { ReactElement, useEffect, useRef } from 'react';
import { Audio } from 'expo-av';
import { getInfoAsync } from 'expo-file-system';
import { useKeepAwake } from 'expo-keep-awake';
import { shallowEqual } from 'react-redux';

import { useTheme } from '../../../../theme';
import { BaseButton } from '../Buttons';
Expand Down Expand Up @@ -32,7 +31,6 @@ export const RecordAudio = (): ReactElement | null => {
const { setRecordingAudio } = useMessageComposerApi();
const { rid, tmid } = useRoomContext();
const server = useAppSelector(state => state.server.server);
const user = useAppSelector(state => ({ id: state.login.user.id, token: state.login.user.token }), shallowEqual);
const permissionToUpload = useCanUploadFile(rid);
useKeepAwake();

Expand Down Expand Up @@ -108,7 +106,7 @@ export const RecordAudio = (): ReactElement | null => {

if (fileInfo) {
if (permissionToUpload) {
await sendFileMessage(rid, fileInfo, tmid, server, user);
await sendFileMessage(rid, fileInfo, tmid, server);
}
}
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions app/containers/MessageComposer/hooks/useAutocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const useAutocomplete = ({
return;
}
const response = await Services.getCommandPreview(text, rid, commandParams);
if (response.success) {
if (response) {
const previewItems = (response.preview?.items || []).map(item => ({
id: item.id,
preview: item,
Expand All @@ -147,7 +147,7 @@ export const useAutocomplete = ({
}
if (type === '!') {
const res = await Services.getListCannedResponse({ text });
if (res.success) {
if (res) {
if (res.cannedResponses.length === 0) {
setItems([
{
Expand Down
4 changes: 2 additions & 2 deletions app/containers/markdown/Hashtag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getSubscriptionByRoomId } from '../../lib/database/services/Subscriptio
import { useAppSelector } from '../../lib/hooks';
import { showErrorAlert } from '../../lib/methods/helpers';
import { goRoom } from '../../lib/methods/helpers/goRoom';
import { Services } from '../../lib/services';
import sdk from '../../lib/services/sdk';
import { useTheme } from '../../theme';
import { sendLoadingEvent } from '../Loading';
import { IUserChannel } from './interfaces';
Expand Down Expand Up @@ -37,7 +37,7 @@ const Hashtag = React.memo(({ hashtag, channels, navToRoomInfo, style = [] }: IH
} else if (navParam.rid) {
sendLoadingEvent({ visible: true });
try {
await Services.getRoomInfo(navParam.rid);
await sdk.get('/v1/rooms.info', { roomId: navParam.rid });
sendLoadingEvent({ visible: false });
navToRoomInfo(navParam);
} catch (error) {
Expand Down
3 changes: 0 additions & 3 deletions app/definitions/ILivechatEditView.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { TextInput } from 'react-native';

import { TSupportedThemes } from '../theme';
import { ILivechatVisitor } from './ILivechatVisitor';
import { ISubscription } from './ISubscription';

export interface ITitle {
Expand All @@ -21,8 +20,6 @@ export interface IInputs {
[key: string]: any;
}

export type TParams = ILivechatVisitor & IInputs;

export interface ILivechat extends ISubscription {
// Param dynamic depends on server
sms?: string;
Expand Down
4 changes: 0 additions & 4 deletions app/definitions/ISlashCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ export interface ISlashCommand {
appId?: string;
}

export interface ISlashCommandResult extends ISlashCommand {
command: string;
}

export type TSlashCommandModel = ISlashCommand & Model;

// For Command Preview ex: /giphy or /tenor
Expand Down
30 changes: 15 additions & 15 deletions app/definitions/IUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,21 @@ export interface IUserSettings {
}
export type TNotifications = 'default' | 'all' | 'mentions' | 'nothing';

export interface INotificationPreferences {
id: string;
enableMessageParserEarlyAdoption: boolean;
desktopNotifications: TNotifications;
pushNotifications: TNotifications;
emailNotificationMode: 'mentions' | 'nothing';
language?: string;
}

export interface IUserPreferences {
user: Pick<IUser, '_id'>;
settings: {
preferences: INotificationPreferences;
};
}
// export interface INotificationPreferences {
// id: string;
// enableMessageParserEarlyAdoption: boolean;
// desktopNotifications: TNotifications;
// pushNotifications: TNotifications;
// emailNotificationMode: 'mentions' | 'nothing';
// language?: string;
// }

// export interface IUserPreferences {
// user: Pick<IUser, '_id'>;
// settings: {
// preferences: INotificationPreferences;
// };
// }

export interface IUser extends IRocketChatRecord, ILoggedUser {
_id: string;
Expand Down
5 changes: 0 additions & 5 deletions app/definitions/rest/helpers/PaginatedRequest.ts

This file was deleted.

5 changes: 0 additions & 5 deletions app/definitions/rest/helpers/PaginatedResult.ts

This file was deleted.

95 changes: 0 additions & 95 deletions app/definitions/rest/helpers/index.ts

This file was deleted.

5 changes: 0 additions & 5 deletions app/definitions/rest/v1/autotranslate.ts

This file was deleted.

Loading