Chore: Remove deprecated typing stream (#4888)
This commit is contained in:
parent
edd0333be1
commit
197616b94c
|
@ -138,6 +138,23 @@ export default class RoomSubscription {
|
||||||
reduxStore.dispatch(removeUserTyping(name));
|
reduxStore.dispatch(removeUserTyping(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (ev === 'user-activity') {
|
||||||
|
const { user } = reduxStore.getState().login;
|
||||||
|
const { UI_Use_Real_Name } = reduxStore.getState().settings;
|
||||||
|
const { subscribedRoom } = reduxStore.getState().room;
|
||||||
|
if (subscribedRoom !== _rid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const [name, activities] = ddpMessage.fields.args;
|
||||||
|
const key = UI_Use_Real_Name ? 'name' : 'username';
|
||||||
|
if (name !== user[key]) {
|
||||||
|
if (activities.includes('user-typing')) {
|
||||||
|
reduxStore.dispatch(addUserTyping(name));
|
||||||
|
}
|
||||||
|
if (!activities.length) {
|
||||||
|
reduxStore.dispatch(removeUserTyping(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (ev === 'deleteMessage') {
|
} else if (ev === 'deleteMessage') {
|
||||||
InteractionManager.runAfterInteractions(async () => {
|
InteractionManager.runAfterInteractions(async () => {
|
||||||
if (ddpMessage && ddpMessage.fields && ddpMessage.fields.args.length > 0) {
|
if (ddpMessage && ddpMessage.fields && ddpMessage.fields.args.length > 0) {
|
||||||
|
|
|
@ -812,10 +812,14 @@ export const addUsersToRoom = (rid: string): Promise<boolean> => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const emitTyping = (room: IRoom, typing = true) => {
|
export const emitTyping = (room: IRoom, typing = true) => {
|
||||||
const { login, settings } = reduxStore.getState();
|
const { login, settings, server } = reduxStore.getState();
|
||||||
const { UI_Use_Real_Name } = settings;
|
const { UI_Use_Real_Name } = settings;
|
||||||
|
const { version: serverVersion } = server;
|
||||||
const { user } = login;
|
const { user } = login;
|
||||||
const name = UI_Use_Real_Name ? user.name : user.username;
|
const name = UI_Use_Real_Name ? user.name : user.username;
|
||||||
|
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '4.0.0')) {
|
||||||
|
return sdk.methodCall('stream-notify-room', `${room}/user-activity`, name, typing ? ['user-typing'] : []);
|
||||||
|
}
|
||||||
return sdk.methodCall('stream-notify-room', `${room}/typing`, name, typing);
|
return sdk.methodCall('stream-notify-room', `${room}/typing`, name, typing);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { twoFactor } from './twoFactor';
|
||||||
import { isSsl } from '../methods/helpers/url';
|
import { isSsl } from '../methods/helpers/url';
|
||||||
import { store as reduxStore } from '../store/auxStore';
|
import { store as reduxStore } from '../store/auxStore';
|
||||||
import { Serialized, MatchPathPattern, OperationParams, PathFor, ResultFor } from '../../definitions/rest/helpers';
|
import { Serialized, MatchPathPattern, OperationParams, PathFor, ResultFor } from '../../definitions/rest/helpers';
|
||||||
import { random } from '../methods/helpers';
|
import { compareServerVersion, random } from '../methods/helpers';
|
||||||
|
|
||||||
class Sdk {
|
class Sdk {
|
||||||
private sdk: typeof Rocketchat;
|
private sdk: typeof Rocketchat;
|
||||||
|
@ -162,7 +162,22 @@ class Sdk {
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribeRoom(...args: any[]) {
|
subscribeRoom(...args: any[]) {
|
||||||
return this.current.subscribeRoom(...args);
|
const { server } = reduxStore.getState();
|
||||||
|
const { version: serverVersion } = server;
|
||||||
|
const topic = 'stream-notify-room';
|
||||||
|
let eventUserTyping;
|
||||||
|
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '4.0.0')) {
|
||||||
|
eventUserTyping = this.subscribe(topic, `${args[0]}/user-activity`, ...args);
|
||||||
|
} else {
|
||||||
|
eventUserTyping = this.subscribe(topic, `${args[0]}/typing`, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Taken from https://github.com/RocketChat/Rocket.Chat.js.SDK/blob/454b4ba784095057b8de862eb99340311b672e15/lib/drivers/ddp.ts#L555
|
||||||
|
return Promise.all([
|
||||||
|
this.subscribe('stream-room-messages', args[0], ...args),
|
||||||
|
eventUserTyping,
|
||||||
|
this.subscribe(topic, `${args[0]}/deleteMessage`, ...args)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsubscribe(subscription: any[]) {
|
unsubscribe(subscription: any[]) {
|
||||||
|
|
Loading…
Reference in New Issue