Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into chor…
Browse files Browse the repository at this point in the history
…e/remove-method-call
  • Loading branch information
tassoevan committed Aug 12, 2022
2 parents 0e73eab + 50af9b2 commit 5df00d0
Show file tree
Hide file tree
Showing 111 changed files with 1,364 additions and 830 deletions.
3 changes: 2 additions & 1 deletion apps/meteor/app/api/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import './v1/misc';
import './v1/permissions';
import './v1/push';
import './v1/roles';
import './v1/rooms';
import './v1/rooms.js';
import './v1/rooms.ts';
import './v1/settings';
import './v1/stats';
import './v1/subscriptions';
Expand Down
14 changes: 4 additions & 10 deletions apps/meteor/app/api/server/v1/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,10 @@ API.v1.addRoute(
projection: fields,
});

const [channels, total] = await Promise.all([
cursor.map((room) => this.composeRoomWithLastMessage(room, this.userId)).toArray(),
totalCount,
]);
const [channels, total] = await Promise.all([cursor.toArray(), totalCount]);

return API.v1.success({
channels,
channels: channels.map((room) => this.composeRoomWithLastMessage(room, this.userId)),
count: channels.length,
offset,
total,
Expand Down Expand Up @@ -492,13 +489,10 @@ API.v1.addRoute(
projection: fields,
});

const [channels, total] = await Promise.all([
cursor.map((room) => this.composeRoomWithLastMessage(room, this.userId)).toArray(),
totalCount,
]);
const [channels, total] = await Promise.all([cursor.toArray(), totalCount]);

return API.v1.success({
channels,
channels: channels.map((room) => this.composeRoomWithLastMessage(room, this.userId)),
offset,
count: channels.length,
total,
Expand Down
14 changes: 4 additions & 10 deletions apps/meteor/app/api/server/v1/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,10 @@ API.v1.addRoute(
projection: fields,
});

const [groups, total] = await Promise.all([
cursor.map((room) => this.composeRoomWithLastMessage(room, this.userId)).toArray(),
totalCount,
]);
const [groups, total] = await Promise.all([cursor.toArray(), totalCount]);

return API.v1.success({
groups,
groups: groups.map((room) => this.composeRoomWithLastMessage(room, this.userId)),
offset,
count: groups.length,
total,
Expand Down Expand Up @@ -626,13 +623,10 @@ API.v1.addRoute(
projection: fields,
});

const [rooms, total] = await Promise.all([
cursor.map((room) => this.composeRoomWithLastMessage(room, this.userId)).toArray(),
totalCount,
]);
const [rooms, total] = await Promise.all([cursor.toArray(), totalCount]);

return API.v1.success({
groups: rooms,
groups: rooms.map((room) => this.composeRoomWithLastMessage(room, this.userId)),
offset,
count: rooms.length,
total,
Expand Down
16 changes: 5 additions & 11 deletions apps/meteor/app/api/server/v1/im.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ API.v1.addRoute(

// TODO: CACHE: Add Breaking notice since we removed the query param

const subscriptions = await Subscriptions.find({ 'u._id': this.userId, 't': 'd' })
const subscriptions = await Subscriptions.find({ 'u._id': this.userId, 't': 'd' }, { projection: { rid: 1 } })
.map((item) => item.rid)
.toArray();

Expand All @@ -443,13 +443,10 @@ API.v1.addRoute(
},
);

const [ims, total] = await Promise.all([
cursor.map((room: IRoom) => this.composeRoomWithLastMessage(room, this.userId)).toArray(),
totalCount,
]);
const [ims, total] = await Promise.all([cursor.toArray(), totalCount]);

return API.v1.success({
ims,
ims: ims.map((room: IRoom) => this.composeRoomWithLastMessage(room, this.userId)),
offset,
count: ims.length,
total,
Expand Down Expand Up @@ -480,13 +477,10 @@ API.v1.addRoute(
},
);

const [rooms, total] = await Promise.all([
cursor.map((room: IRoom) => this.composeRoomWithLastMessage(room, this.userId)).toArray(),
totalCount,
]);
const [rooms, total] = await Promise.all([cursor.toArray(), totalCount]);

return API.v1.success({
ims: rooms,
ims: rooms.map((room: IRoom) => this.composeRoomWithLastMessage(room, this.userId)),
offset,
count: rooms.length,
total,
Expand Down
39 changes: 39 additions & 0 deletions apps/meteor/app/api/server/v1/rooms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Meteor } from 'meteor/meteor';
import Ajv from 'ajv';

import { API } from '../api';

// TO-DO: Replace this instance by only one Ajv import
const ajv = new Ajv({ coerceTypes: true });

type GETRoomsNameExists = {
roomName: string;
};

const GETRoomsNameExistsSchema = {
type: 'object',
properties: {
roomName: {
type: 'string',
},
},
required: ['roomName'],
additionalProperties: false,
};

export const isGETRoomsNameExists = ajv.compile<GETRoomsNameExists>(GETRoomsNameExistsSchema);

API.v1.addRoute(
'rooms.nameExists',
{
authRequired: true,
validateParams: isGETRoomsNameExists,
},
{
get() {
const { roomName } = this.queryParams;

return API.v1.success({ exists: Meteor.call('roomNameExists', roomName) });
},
},
);
10 changes: 9 additions & 1 deletion apps/meteor/app/lib/server/startup/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1555,11 +1555,19 @@ settingsRegistry.addGroup('Layout', function () {
type: 'boolean',
public: true,
});
this.add('Layout_Custom_Body', false, {
type: 'boolean',
public: true,
});
this.add(
'Layout_Home_Body',
'<p>Welcome to Rocket.Chat!</p>\n<p>The Rocket.Chat desktops apps for Windows, macOS and Linux are available to download <a title="Rocket.Chat desktop apps" href="https://rocket.chat/download" target="_blank" rel="noopener">here</a>.</p><p>The native mobile app, Rocket.Chat,\n for Android and iOS is available from <a title="Rocket.Chat on Google Play" href="https://play.google.com/store/apps/details?id=chat.rocket.android" target="_blank" rel="noopener">Google Play</a> and the <a title="Rocket.Chat on the App Store" href="https://itunes.apple.com/app/rocket-chat/id1148741252" target="_blank" rel="noopener">App Store</a>.</p>\n<p>For further help, please consult the <a title="Rocket.Chat Documentation" href="https://rocket.chat/docs/" target="_blank" rel="noopener">documentation</a>.</p>\n<p>If you\'re an admin, feel free to change this content via <strong>Administration</strong> &rarr; <strong>Layout</strong> &rarr; <strong>Home Body</strong>. Or clicking <a title="Home Body Layout" href="/admin/Layout">here</a>.</p>',
'<p>~~~~ Default html example ~~~~</p>\n<strong>Welcome to (ENTER ORGANIZATION NAME HERE)</strong>\n\n<p>All general communications should be done through #general</p>\n<p>find more information <a href="INSERT LINK" target="_blank" rel="noopener">here</a></p>',
{
type: 'code',
enableQuery: {
_id: 'Layout_Custom_Body',
value: true,
},
code: 'text/html',
multiline: true,
public: true,
Expand Down
100 changes: 0 additions & 100 deletions apps/meteor/app/theme/client/imports/components/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@
align-items: center;
}

&--burger {
display: none;
}

&__name {
overflow: hidden;

Expand All @@ -78,28 +74,6 @@
text-overflow: ellipsis;
}

&__section-title {
color: var(--header-title-username-color-darker);

font-weight: var(--header-title-username-weight);
}

&__section-help {
flex: 1 1;
}

&__section-button {
display: flex;
flex: 1 1 100%;
justify-content: flex-end;

/* max-width: use this to allign the buttons with the form */
}

&__section-button > button {
margin: 0.3rem;
}

&-title {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -187,79 +161,5 @@
flex-direction: row;
align-items: center;
}

&--burger {
display: flex;

margin: 0;
padding: 0;
}
}
}

.burger {
position: relative;

cursor: pointer;
transition: transform 0.2s ease-out 0.1s;
will-change: transform;

& .burger__line {
display: block;

width: 20px;
height: 2px;
margin: 5px 0;

transition: transform 0.2s ease-out;

opacity: 0.8;
}

& .unread-burger-alert {
position: absolute;
z-index: 3;
bottom: 13px;
left: 10px;

min-width: 18px;
height: 18px;
padding: 0 4px;

text-align: center;

border-radius: 20px;

font-size: 12px;
font-weight: bold;
line-height: 18px;
}

&.menu-opened .burger__line {
&:nth-child(1),
&:nth-child(3) {
transform-origin: 50%, 50%, 0;

opacity: 1;
}

&:nth-child(1) {
transform: translate(-25%, 3px) rotate(-45deg) scale(0.5, 1);
}

&:nth-child(3) {
transform: translate(-25%, -3px) rotate(45deg) scale(0.5, 1);
}
}
}

@media (max-width: 780px) {
.rc-header {
&--burger {
display: flex;

margin: 0;
padding: 0;
}
}
}
Loading

0 comments on commit 5df00d0

Please sign in to comment.