Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
941b03d
Add `RoomLayout`; update `RoomNotFound` and `RoomSkeleton`
tassoevan Aug 23, 2022
5c9e0f4
Update `Room`
tassoevan Aug 23, 2022
854d31a
Migrate `LazyComponent`
tassoevan Aug 24, 2022
7d42209
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 24, 2022
15723cb
Replace undescore's `omit` helper
tassoevan Aug 24, 2022
42b10a1
Fix silly bug
tassoevan Aug 24, 2022
c1d3099
Rearrange `Room` components
tassoevan Aug 25, 2022
6966363
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 25, 2022
371c945
Remove unused templates
tassoevan Aug 25, 2022
f20e93f
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 25, 2022
ad238bf
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 25, 2022
bf13222
Partially convert `roomOld` template into `RoomBody`
tassoevan Aug 26, 2022
cc87247
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 26, 2022
2d700b1
Extract composer
tassoevan Aug 26, 2022
0f5166d
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 26, 2022
209b7cf
Work around `dragenter` issue
tassoevan Aug 26, 2022
efd4a50
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 26, 2022
e208254
Merge branches 'refactor/room' and 'develop' of github.com:RocketChat…
tassoevan Aug 26, 2022
6eb6fc5
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 26, 2022
f0b4819
Upgrade E2E test
tassoevan Aug 26, 2022
6d26802
Add minor components
tassoevan Aug 29, 2022
c7b1525
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 29, 2022
687386e
Fix broken query for legacy message template
tassoevan Aug 30, 2022
747083e
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 30, 2022
a5c6169
Shrink helpers
tassoevan Aug 30, 2022
84f0334
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 30, 2022
3407b96
Revert "Shrink helpers"
tassoevan Aug 30, 2022
cc0d479
Remove unused helpers
tassoevan Aug 30, 2022
0aea671
Inject dependencies via data context
tassoevan Aug 31, 2022
a3abca1
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 31, 2022
80e410b
Inject dependencies via data context
tassoevan Aug 31, 2022
8ce30f6
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 31, 2022
5a7c773
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 31, 2022
56e47c4
Replace `underscore` helpers
tassoevan Sep 1, 2022
7dce8ad
Dry out the `room` template
tassoevan Sep 2, 2022
48d419d
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Sep 2, 2022
154ce72
Remove `roomOld` template
tassoevan Sep 2, 2022
14df033
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Sep 2, 2022
fee9e4d
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Sep 5, 2022
54e2925
Remove some implicit `any`s
tassoevan Sep 5, 2022
1eebc18
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Sep 5, 2022
b116b90
Merge branch 'develop' into refactor/room
ggazzo Sep 5, 2022
ba15a30
Merge remote-tracking branch 'origin/develop' into refactor/room
ggazzo Sep 6, 2022
c826661
Merge branch 'develop' into refactor/room
sampaiodiego Sep 8, 2022
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
8 changes: 8 additions & 0 deletions apps/meteor/app/autotranslate/client/lib/actionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Meteor.startup(() => {
Messages.update({ _id: message._id }, { [action]: { autoTranslateShowInverse: true } });
},
condition({ message, user }) {
if (!user) {
return false;
}

return Boolean(message?.u && message.u._id !== user._id && isTranslatedMessage(message) && message.autoTranslateShowInverse);
},
order: 90,
Expand All @@ -54,6 +58,10 @@ Meteor.startup(() => {
Messages.update({ _id: message._id }, { [action]: { autoTranslateShowInverse: true } });
},
condition({ message, user }) {
if (!user) {
return false;
}

return Boolean(message?.u && message.u._id !== user._id && isTranslatedMessage(message) && !message.autoTranslateShowInverse);
},
order: 90,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Meteor.startup(function () {
return false;
}

if (!user) {
return false;
}

return uid !== user._id ? hasPermission('start-discussion-other-user') : hasPermission('start-discussion');
},
order: 1,
Expand Down
3 changes: 0 additions & 3 deletions apps/meteor/app/discussion/client/views/DiscussionTabbar.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import _ from 'underscore';
import type { MessageAttachment, FileAttachmentProps, IUser } from '@rocket.chat/core-typings';
import { Rooms, Uploads } from '@rocket.chat/models';

import { callbacks } from '../../../../lib/callbacks';
import { FileUpload } from '../lib/FileUpload';
import { canAccessRoom } from '../../../authorization/server/functions/canAccessRoom';
import { SystemLogger } from '../../../../server/lib/logger/system';
import { omit } from '../../../../lib/utils/omit';

Meteor.methods({
async sendFileMessage(roomId, _store, file, msgData = {}) {
Expand Down Expand Up @@ -36,7 +36,7 @@ Meteor.methods({
tmid: Match.Optional(String),
});

await Uploads.updateFileComplete(file._id, user._id, _.omit(file, '_id'));
await Uploads.updateFileComplete(file._id, user._id, omit(file, '_id'));

const fileUrl = FileUpload.getPath(`${file._id}/${encodeURI(file.name)}`);

Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/app/integrations/server/lib/triggerHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getRoomByNameOrIdWithOptionToJoin, processWebhookMessage } from '../../
import { outgoingLogger } from '../logger';
import { outgoingEvents } from '../../lib/outgoingEvents';
import { fetch } from '../../../../server/lib/http/fetch';
import { omit } from '../../../../lib/utils/omit';

export class RocketChatIntegrationHandler {
constructor() {
Expand Down Expand Up @@ -103,7 +104,7 @@ export class RocketChatIntegrationHandler {
history.data = { ...data };

if (data.user) {
history.data.user = _.omit(data.user, ['services']);
history.data.user = omit(data.user, 'services');
}

if (data.room) {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/mentions-flextab/client/actionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Meteor.startup(function () {
},
);
}
RoomHistoryManager.getSurroundingMessages(message, 50);
RoomHistoryManager.getSurroundingMessages(message);
},
order: 100,
group: ['message', 'menu'],
Expand Down
5 changes: 5 additions & 0 deletions apps/meteor/app/message-mark-as-unread/client/actionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ Meteor.startup(() => {
if (isLivechatRoom) {
return false;
}

if (!user) {
return false;
}

return message.u._id !== user._id;
},
order: 10,
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/message-pin/client/actionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Meteor.startup(function () {
},
);
}
return RoomHistoryManager.getSurroundingMessages(message, 50);
return RoomHistoryManager.getSurroundingMessages(message);
},
condition({ subscription }) {
return !!subscription;
Expand Down
10 changes: 5 additions & 5 deletions apps/meteor/app/message-star/client/actionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Meteor.startup(function () {
return false;
}

return !Array.isArray(message.starred) || !message.starred.find((star: any) => star._id === user._id);
return !Array.isArray(message.starred) || !message.starred.find((star: any) => star._id === user?._id);
},
order: 9,
group: 'menu',
Expand All @@ -58,7 +58,7 @@ Meteor.startup(function () {
return false;
}

return Boolean(message.starred?.find((star: any) => star._id === user._id));
return Boolean(message.starred?.find((star: any) => star._id === user?._id));
},
order: 9,
group: 'menu',
Expand Down Expand Up @@ -90,14 +90,14 @@ Meteor.startup(function () {
},
);
}
RoomHistoryManager.getSurroundingMessages(message, 50);
RoomHistoryManager.getSurroundingMessages(message);
},
condition({ message, subscription, user }) {
if (subscription == null || !settings.get('Message_AllowStarring')) {
return false;
}

return Boolean(message.starred?.find((star) => star._id === user._id));
return Boolean(message.starred?.find((star) => star._id === user?._id));
},
order: 100,
group: ['message', 'menu'],
Expand All @@ -120,7 +120,7 @@ Meteor.startup(function () {
return false;
}

return Boolean(message.starred?.find((star) => star._id === user._id));
return Boolean(message.starred?.find((star) => star._id === user?._id));
},
order: 101,
group: 'menu',
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/meteor-autocomplete/client/templates.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Blaze } from 'meteor/blaze';
import { Template } from 'meteor/templating';
import _ from 'underscore';

import { omit } from '../../../lib/utils/omit';
import AutoComplete from './autocomplete-client';

// Events on template instances, sent to the autocomplete class
Expand All @@ -25,7 +25,7 @@ Template.inputAutocomplete.events(acEvents);
Template.textareaAutocomplete.events(acEvents);

const attributes = function () {
return _.omit(this, 'settings'); // Render all but the settings parameter
return omit(this, 'settings'); // Render all but the settings parameter
};

const autocompleteHelpers = {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/models/server/models/_BaseDb.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Match } from 'meteor/check';
import { Mongo } from 'meteor/mongo';
import _ from 'underscore';

import { setUpdatedAt } from '../lib/setUpdatedAt';
import { trash } from '../../../../server/database/trash';
import { omit } from '../../../../lib/utils/omit';

const baseName = 'rocketchat_';

Expand Down Expand Up @@ -168,7 +168,7 @@ export class BaseDb {
record._deletedAt = new Date();
record.__collection__ = this.name;

trash.upsert({ _id: record._id }, _.omit(record, '_id'));
trash.upsert({ _id: record._id }, omit(record, '_id'));
}

query = { _id: { $in: ids } };
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/search/client/provider/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Meteor.startup(function () {
}

if (Session.get('openedRoom') === message.rid) {
return RoomHistoryManager.getSurroundingMessages(message, 50);
return RoomHistoryManager.getSurroundingMessages(message);
}

goToRoomById(message.rid);
Expand All @@ -48,7 +48,7 @@ Meteor.startup(function () {
}

window.setTimeout(() => {
RoomHistoryManager.getSurroundingMessages(message, 50);
RoomHistoryManager.getSurroundingMessages(message);
}, 400);
// 400ms is popular among game devs as a good delay before transition starts
// ie. 50, 100, 200, 400, 800 are the favored timings
Expand Down
29 changes: 0 additions & 29 deletions apps/meteor/app/theme/client/imports/general/base_old.css
Original file line number Diff line number Diff line change
Expand Up @@ -1643,35 +1643,6 @@
}
}

.rc-old .ticks-bar {
position: absolute;
z-index: 1;
right: 2px;

width: 10px;
height: 100%;

pointer-events: none;

& .tick {
position: absolute;
top: 50%;

width: 100%;
height: 2px;

border-radius: 2px;

&--me {
background-color: var(--mention-link-me-text-color);
}

&--group {
background-color: var(--mention-link-group-text-color);
}
}
}

.message {
position: relative;
z-index: 1;
Expand Down
5 changes: 0 additions & 5 deletions apps/meteor/app/theme/client/imports/general/rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,6 @@
}
}

& .ticks-bar {
right: auto;
left: 2px;
}

& .fixed-title {
right: 0;
left: auto;
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/threads/client/messageAction/follow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Meteor.startup(function () {
if (isLivechatRoom) {
return false;
}
return !replies.includes(user._id);
return user?._id ? !replies.includes(user._id) : false;
},
order: 2,
group: 'menu',
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/threads/client/messageAction/unfollow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Meteor.startup(function () {
replies = parentMessage.replies || [];
}
}
return replies.includes(user._id);
return user?._id ? replies.includes(user._id) : false;
},
order: 2,
group: 'menu',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { callbacks } from '../../../../lib/callbacks';
import Notifications from '../../../notifications/client/lib/Notifications';
import { getConfig } from '../../../../client/lib/utils/getConfig';
import { call } from '../../../../client/lib/utils/call';
import { omit } from '../../../../lib/utils/omit';

const wrap =
(fn) =>
Expand Down Expand Up @@ -228,7 +229,7 @@ export class CachedCollection extends Emitter {
this.log(`${data.length} records loaded from server`);
data.forEach((record) => {
callbacks.run(`cachedCollection-loadFromServer-${this.name}`, record, 'changed');
this.collection.direct.upsert({ _id: record._id }, _.omit(record, '_id'));
this.collection.direct.upsert({ _id: record._id }, omit(record, '_id'));

this.onSyncData('changed', record);

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/ui-utils/client/lib/MessageAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type MessageActionContext = 'message' | 'threads' | 'message-mobile' | 'pinned'

type MessageActionConditionProps = {
message: IMessage;
user: IUser;
user: IUser | undefined;
room: IRoom;
subscription?: ISubscription;
context?: MessageActionContext;
Expand Down
22 changes: 8 additions & 14 deletions apps/meteor/app/ui-utils/client/lib/RoomHistoryManager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { ReactiveVar } from 'meteor/reactive-var';
import { Blaze } from 'meteor/blaze';
import { v4 as uuidv4 } from 'uuid';
import differenceInMilliseconds from 'date-fns/differenceInMilliseconds';
import { Emitter } from '@rocket.chat/emitter';
import type { IMessage, IRoom, ISubscription, IUser } from '@rocket.chat/core-typings';
import type { MutableRefObject } from 'react';

import { waitUntilWrapperExists } from './waitUntilWrapperExists';
import { readMessage } from './readMessages';
Expand All @@ -17,7 +17,6 @@ import {
setHighlightMessage,
clearHighlightMessage,
} from '../../../../client/views/room/MessageList/providers/messageHighlightSubscription';
import type { RoomTemplateInstance } from '../../../ui/client/views/app/lib/RoomTemplateInstance';
import { normalizeThreadMessage } from '../../../../client/lib/normalizeThreadMessage';

export async function upsertMessage(
Expand Down Expand Up @@ -219,15 +218,14 @@ class RoomHistoryManagerClass extends Emitter {
});
}

public async getMoreNext(rid: IRoom['_id'], limit = defaultLimit) {
public async getMoreNext(rid: IRoom['_id'], atBottomRef: MutableRefObject<boolean>) {
const room = this.getRoom(rid);
if (Tracker.nonreactive(() => room.hasMoreNext.get()) !== true) {
return;
}

await this.queue();
const instance = Blaze.getView($('.messages-box .wrapper')[0]).templateInstance() as RoomTemplateInstance;
instance.atBottom = false;
atBottomRef.current = false;

room.isLoading.set(true);

Expand All @@ -237,7 +235,7 @@ class RoomHistoryManagerClass extends Emitter {

if (lastMessage?.ts) {
const { ts } = lastMessage;
const result = await callWithErrorHandling('loadNextMessages', rid, ts, limit);
const result = await callWithErrorHandling('loadNextMessages', rid, ts, defaultLimit);
upsertMessageBulk({
msgs: Array.from(result.messages).filter((msg) => msg.t !== 'command'),
subscription,
Expand All @@ -249,7 +247,7 @@ class RoomHistoryManagerClass extends Emitter {
}

room.loaded += result.messages.length;
if (result.messages.length < limit) {
if (result.messages.length < defaultLimit) {
room.hasMoreNext.set(false);
}
}
Expand Down Expand Up @@ -288,15 +286,11 @@ class RoomHistoryManagerClass extends Emitter {
room.loaded = undefined;
}

public async getSurroundingMessages(message?: Pick<IMessage, '_id' | 'rid'> & { ts?: Date }, limit = defaultLimit) {
public async getSurroundingMessages(message?: Pick<IMessage, '_id' | 'rid'> & { ts?: Date }, atBottomRef?: MutableRefObject<boolean>) {
if (!message || !message.rid) {
return;
}

const w = (await waitUntilWrapperExists()) as HTMLElement;

const instance = Blaze.getView(w).templateInstance() as RoomTemplateInstance;

const surroundingMessage = ChatMessage.findOne({ _id: message._id, _hidden: { $ne: true } });

if (surroundingMessage) {
Expand Down Expand Up @@ -336,7 +330,7 @@ class RoomHistoryManagerClass extends Emitter {

const subscription = ChatSubscription.findOne({ rid: message.rid });

const result = await callWithErrorHandling('loadSurroundingMessages', message, limit);
const result = await callWithErrorHandling('loadSurroundingMessages', message, defaultLimit);

if (!result || !result.messages) {
return;
Expand Down Expand Up @@ -368,7 +362,7 @@ class RoomHistoryManagerClass extends Emitter {

room.isLoading.set(false);
const messages = wrapper[0];
instance.atBottom = !result.moreAfter && messages.scrollTop >= messages.scrollHeight - messages.clientHeight;
if (atBottomRef) atBottomRef.current = !result.moreAfter && messages.scrollTop >= messages.scrollHeight - messages.clientHeight;

setTimeout(() => {
msgElement.removeClass('highlight');
Expand Down
Loading