Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions app/definitions/rest/v1/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export type ChatEndpoints = {
message: IMessage;
};
};
'chat.getMessageByFileId': {
GET: (params: { fileId: string }) => {
message: IMessage;
};
};
'chat.followMessage': {
POST: (params: { mid: IMessage['_id'] }) => void;
};
Expand Down
4 changes: 4 additions & 0 deletions app/lib/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
import { TEAM_TYPE } from '../../definitions/ITeam';
import { type OperationParams, type ResultFor } from '../../definitions/rest/helpers';
import { type SubscriptionsEndpoints } from '../../definitions/rest/v1/subscriptions';
import { Encryption } from '../encryption';

Check warning on line 25 in app/lib/services/restApi.ts

View workflow job for this annotation

GitHub Actions / ESLint and Test / run-eslint-and-test

import(no-cycle)

Dependency cycle detected

Check warning on line 25 in app/lib/services/restApi.ts

View workflow job for this annotation

GitHub Actions / format

import(no-cycle)

Dependency cycle detected
import { type RoomTypes, roomTypeToApiType } from '../methods/roomTypeToApiType';
import { uploadUserAvatarMultipart } from '../methods/uploadAvatar/uploadAvatar';
import { unsubscribeRooms } from '../methods/subscribeRooms';

Check warning on line 28 in app/lib/services/restApi.ts

View workflow job for this annotation

GitHub Actions / ESLint and Test / run-eslint-and-test

import(no-cycle)

Dependency cycle detected

Check warning on line 28 in app/lib/services/restApi.ts

View workflow job for this annotation

GitHub Actions / format

import(no-cycle)

Dependency cycle detected
import { compareServerVersion, getBundleId, isIOS } from '../methods/helpers';

Check warning on line 29 in app/lib/services/restApi.ts

View workflow job for this annotation

GitHub Actions / ESLint and Test / run-eslint-and-test

import(no-cycle)

Dependency cycle detected

Check warning on line 29 in app/lib/services/restApi.ts

View workflow job for this annotation

GitHub Actions / format

import(no-cycle)

Dependency cycle detected
import { getDeviceToken } from '../notifications';

Check warning on line 30 in app/lib/services/restApi.ts

View workflow job for this annotation

GitHub Actions / ESLint and Test / run-eslint-and-test

import(no-cycle)

Dependency cycle detected

Check warning on line 30 in app/lib/services/restApi.ts

View workflow job for this annotation

GitHub Actions / format

import(no-cycle)

Dependency cycle detected
import NativeVoipModule from '../native/NativeVoip';
import { store as reduxStore } from '../store/auxStore';
import sdk from './sdk';

Check warning on line 33 in app/lib/services/restApi.ts

View workflow job for this annotation

GitHub Actions / ESLint and Test / run-eslint-and-test

import(no-cycle)

Dependency cycle detected
import fetch from '../methods/helpers/fetch';
import log from '../methods/helpers/log';

Expand Down Expand Up @@ -786,6 +786,10 @@
});
};

export const getMessageByFileId = (fileId: string) =>
// RC 8.10.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to wait the backend PR to merge so we're sure about the version

sdk.get('chat.getMessageByFileId', { fileId });

export const getMessages = ({
roomId,
type,
Expand Down Expand Up @@ -898,7 +902,7 @@
updatedSince
});

export const runSlashCommand = (command: string, roomId: string, params: string, triggerId?: string, tmid?: string) =>

Check warning on line 905 in app/lib/services/restApi.ts

View workflow job for this annotation

GitHub Actions / ESLint and Test / run-eslint-and-test

eslint(max-params)

Arrow function has too many parameters (5). Maximum allowed is 4.
// RC 0.60.2
sdk.post('commands.run', {
command,
Expand All @@ -916,14 +920,14 @@
params
});

export const executeCommandPreview = (
command: string,
params: string,
roomId: string,
previewItem: IPreviewItem,
triggerId: string,
tmid?: string
) =>

Check warning on line 930 in app/lib/services/restApi.ts

View workflow job for this annotation

GitHub Actions / ESLint and Test / run-eslint-and-test

eslint(max-params)

Arrow function has too many parameters (6). Maximum allowed is 4.
// RC 0.65.0
sdk.post('commands.preview', {
command,
Expand Down
38 changes: 34 additions & 4 deletions app/views/MessagesView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ import {
type TAnyMessageModel,
type IUrl
} from '../../definitions';
import { getFiles, getMessages, getPinnedMessages, togglePinMessage, toggleStarMessage } from '../../lib/services/restApi';
import {
getFiles,
getMessageByFileId,
getMessages,
getPinnedMessages,
togglePinMessage,
toggleStarMessage
} from '../../lib/services/restApi';
import { compareServerVersion, showErrorAlert } from '../../lib/methods/helpers';
import { type TNavigation } from '../../stacks/stackType';
import AudioManager from '../../lib/methods/AudioManager';
import { Encryption } from '../../lib/encryption';
Expand All @@ -54,6 +62,7 @@ interface IMessagesViewProps {
showActionSheet: (params: { options: string[]; hasCancel: boolean }) => void;
isMasterDetail: boolean;
insets: EdgeInsets;
serverVersion: string | null;
}

interface IMessagesViewState {
Expand Down Expand Up @@ -136,11 +145,31 @@ class MessagesView extends Component<IMessagesViewProps, IMessagesViewState> {
navigation.navigate('RoomInfoView', navParam);
};

resolveMessageId = async (item: IMessage): Promise<string | null> => {
const { route, serverVersion } = this.props;
if (route.params?.name !== 'Files' || compareServerVersion(serverVersion, 'lowerThan', '8.9.0')) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a gap that makes 8.9.* call the new logic, but your comment on the other file says 8.10.0.

return item._id;
Comment thread
OtavioStasiak marked this conversation as resolved.
}

try {
const result = await getMessageByFileId(item._id);
if (result.success && result.message) {
return result.message._id;
}
} catch {}
return null;
};

jumpToMessage = async ({ item }: { item: IMessage }) => {
const { isMasterDetail } = this.props;
const jumpToMessageId = await this.resolveMessageId(item);
if (!jumpToMessageId) {
showErrorAlert(I18n.t('Message_not_found'), I18n.t('Oops'));
return;
}
let params: IParams = {
rid: this.rid,
jumpToMessageId: item._id,
jumpToMessageId,
t: this.t,
room: this.room
};
Expand All @@ -149,7 +178,7 @@ class MessagesView extends Component<IMessagesViewProps, IMessagesViewState> {
params = {
...params,
tmid: item.tmid,
name: await getThreadName(this.rid, item.tmid, item._id),
name: await getThreadName(this.rid, item.tmid, jumpToMessageId),
t: SubscriptionType.THREAD
};
Navigation.push('RoomView', params);
Expand Down Expand Up @@ -367,7 +396,8 @@ class MessagesView extends Component<IMessagesViewProps, IMessagesViewState> {

const mapStateToProps = (state: IApplicationState) => ({
baseUrl: state.server.server,
user: getUserSelector(state)
user: getUserSelector(state),
serverVersion: state.server.version
});

export default connect(mapStateToProps)(withTheme(withActionSheet(withMasterDetail(withSafeAreaInsets(MessagesView)))));
Loading