Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Migrate modules related to room template to TypeScript #25881

Merged
merged 50 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3729f4b
Extract `room` template helpers
tassoevan Aug 12, 2022
9340338
Delete unused helper
tassoevan Aug 12, 2022
3dba5f6
Split more modules
tassoevan Aug 13, 2022
cca22cf
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 16, 2022
1c19149
Migrate events and helpers to TypeScript
tassoevan Aug 16, 2022
fa274df
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 16, 2022
a9e1f1b
Migrate `room` template
tassoevan Aug 17, 2022
f08b12f
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 17, 2022
0260197
Refactor a little more
tassoevan Aug 17, 2022
501206b
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 17, 2022
e00b582
Migrate `messageContext`
tassoevan Aug 17, 2022
76c15e9
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 17, 2022
82787b3
Migrate barrel export
tassoevan Aug 17, 2022
e75040f
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 17, 2022
9b23c02
Adjust some types
tassoevan Aug 17, 2022
456b13e
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 17, 2022
5767c1d
Fix isomorphic export
tassoevan Aug 17, 2022
8ca67a9
Migrate `ChatMessages`
tassoevan Aug 18, 2022
ab4c7a4
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 18, 2022
79d5cae
Upgrade `caniuse-lite`
tassoevan Aug 18, 2022
e04f67f
Import `room` template
tassoevan Aug 18, 2022
6151a46
Rearrange exports
tassoevan Aug 18, 2022
7b9856e
Migrate `thread` template
tassoevan Aug 18, 2022
3ba30da
Set `RoomManger` imports
tassoevan Aug 18, 2022
008ba97
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 18, 2022
51c0f2b
Migrate `RoomManager`
tassoevan Aug 18, 2022
6bd1bec
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 18, 2022
3fc42a3
Fix broken import
tassoevan Aug 18, 2022
c44ac4c
Migrate `RoomHistoryManager`
tassoevan Aug 19, 2022
5d881af
Migrate `readMessage`
tassoevan Aug 19, 2022
5c471e6
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 19, 2022
fe5baff
Migrate `ChatMessage`
tassoevan Aug 19, 2022
7ff7035
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 19, 2022
614b14e
Migrate `messageBox`
tassoevan Aug 19, 2022
2db2276
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 19, 2022
8500b62
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 19, 2022
44b487e
Migrate `openRoom`
tassoevan Aug 19, 2022
e253a7c
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 19, 2022
6b9cb6c
Migrate minor templates
tassoevan Aug 19, 2022
c63d4f4
Migrate `messageBox` template
tassoevan Aug 19, 2022
7bb95d7
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 19, 2022
fe0e854
Fix broken imports
tassoevan Aug 19, 2022
3b13957
Remove big whoopsie
tassoevan Aug 19, 2022
0863f5d
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 19, 2022
ebd55c5
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 19, 2022
e3fbff1
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 20, 2022
7deb45d
Remove some implicit `any`s
tassoevan Aug 20, 2022
4cf329a
Merge branch 'develop' into refactor/room-template
ggazzo Aug 22, 2022
af011b8
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
tassoevan Aug 22, 2022
05eab63
Merge branch 'develop' into refactor/room-template
kodiakhq[bot] Aug 22, 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
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/lib/getServerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { hasPermissionAsync } from '../../../authorization/server/functions/hasP

type ServerInfo =
| {
info: Info;
info: typeof Info;
}
| {
version: string | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Meteor.startup(function () {
imperativeModal.open({
component: CreateDiscussion,
props: {
defaultParentRoom: room.prid || room._id,
defaultParentRoom: room?.prid || room?._id,
onClose: imperativeModal.close,
parentMessageId: message._id,
nameSuggestion: message?.msg?.substr(0, 140),
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/emoji/lib/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ export const emoji = {
},
},
},
/** @type {Record<string, unknown>} */
list: {},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { FlowRouter } from 'meteor/kadira:flow-router';
import { ChatRoom, CachedChatRoom } from '../../../../models/client';
import { callWithErrorHandling } from '../../../../../client/lib/utils/callWithErrorHandling';
import { APIClient } from '../../../../utils/client';
import { RoomManager } from '../../../../ui-utils/client/lib/RoomManager';
import { inquiryDataStream } from '../../lib/stream/inquiry';
import { dispatchToastMessage } from '../../../../../client/lib/toast';
import './livechatReadOnly.html';
Expand Down Expand Up @@ -91,6 +90,8 @@ Template.livechatReadOnly.onCreated(async function () {
this.inquiry.set(inquiry);
};

this.roomDataStream = new Meteor.Streamer('room-data');

Meteor.call('livechat:getRoutingConfig', (err, config) => {
if (config) {
this.routingConfig.set(config);
Expand All @@ -108,7 +109,7 @@ Template.livechatReadOnly.onCreated(async function () {
const { room } = await APIClient.get(`/v1/rooms.info`, { roomId });
this.room.set(room);
if (room && room._id) {
RoomManager.roomStream.on(roomId, (room) => this.room.set(room));
this.roomDataStream.on(roomId, (room) => this.room.set(room));
}

this.preparing.set(false);
Expand All @@ -124,5 +125,5 @@ Template.livechatReadOnly.onDestroyed(function () {
}

const { rid } = Template.currentData();
RoomManager.roomStream.removeListener(rid);
this.roomDataStream.removeListener(rid);
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { settings } from '../../../../../settings';
import { t } from '../../../../../utils';
import { hasRole, hasPermission, hasAtLeastOnePermission } from '../../../../../authorization';
import { APIClient } from '../../../../../utils/client';
import { RoomManager } from '../../../../../ui-utils/client';
import { getCustomFormTemplate } from '../customTemplates/register';
import { Markdown } from '../../../../../markdown/client';
import { formatDateAndTime } from '../../../../../../client/lib/utils/formatDateAndTime';
Expand Down Expand Up @@ -414,8 +413,10 @@ Template.visitorInfo.onCreated(function () {
this.updateRoom(room);
};

this.roomDataStream = new Meteor.Streamer('room-data');

if (rid) {
RoomManager.roomStream.on(rid, this.updateRoom);
this.roomDataStream.on(rid, this.updateRoom);
loadRoomData(rid);
}

Expand All @@ -436,5 +437,5 @@ Template.visitorInfo.onCreated(function () {

Template.visitorInfo.onDestroyed(function () {
const { rid } = Template.currentData();
RoomManager.roomStream.removeListener(rid, this.updateRoom);
this.roomDataStream.removeListener(rid, this.updateRoom);
});
20 changes: 0 additions & 20 deletions apps/meteor/app/models/client/models/ChatMessage.js

This file was deleted.

32 changes: 32 additions & 0 deletions apps/meteor/app/models/client/models/ChatMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { IMessage, IRoom } from '@rocket.chat/core-typings';
import { Mongo } from 'meteor/mongo';

class ChatMessageCollection extends Mongo.Collection<IMessage & { ignored?: boolean }> {
constructor() {
super(null);
}

setReactions(messageId: IMessage['_id'], reactions: IMessage['reactions']) {
return this.update({ _id: messageId }, { $set: { reactions } });
}

unsetReactions(messageId: IMessage['_id']) {
return this.update({ _id: messageId }, { $unset: { reactions: 1 } });
}

findOneByRoomIdAndMessageId(rid: IRoom['_id'], messageId: IMessage['_id'], options?: Mongo.Options<IMessage>) {
const query = {
rid,
_id: messageId,
};

return this.findOne(query, options);
}
}

// TODO: check if we can dodge these missing typings from Meteor Collection Hooks
export const ChatMessage = new ChatMessageCollection() as unknown as Mongo.Collection<IMessage & { ignored?: boolean }> & {
direct: Mongo.Collection<IMessage, IMessage>;

queries: unknown[];
};
2 changes: 1 addition & 1 deletion apps/meteor/app/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';

if (Meteor.isClient) {
module.exports = require('./client/index.js');
module.exports = require('./client/index');
}
if (Meteor.isServer) {
module.exports = require('./server/index');
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/otr/client/OTRRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class OTRRoom implements IOTRRoom {
}
}

async encrypt(message: IMessage): Promise<string> {
async encrypt(message: Pick<IMessage, '_id' | 'msg'>): Promise<string> {
try {
const data = new TextEncoder().encode(
EJSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { callWithErrorHandling } from '../../../../client/lib/utils/callWithErro
import './messageBoxFollow.html';

Template.messageBoxFollow.events({
'click .js-follow'() {
'click .js-follow'(this: { tmid: string }) {
const { tmid } = this;
callWithErrorHandling('followMessage', { mid: tmid });
},
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/threads/client/flextab/thread.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="dropzone-overlay {{isDropzoneDisabled}} background-transparent-darkest color-content-background-color">{{_ dragAndDropLabel}}</div>
<div class="thread-list js-scroll-thread">
<ul class="thread">
{{# with messageContext}}
{{#with messageContext}}
{{#if isLoading}}
<li class="load-more">
{{> loading}}
Expand All @@ -19,7 +19,7 @@
</div>
{{> messageBox messageBoxData}}
<footer class="thread-footer">
{{# with checkboxData }}
{{#with checkboxData }}
<div style="display: flex;">
{{> Checkbox . }}
</div>
Expand Down
Loading