Skip to content

Commit

Permalink
Merge pull request RocketChat#184 from WideChat/revert-182-fix_JtM
Browse files Browse the repository at this point in the history
Revert "Fix jump to message in mobile view"
  • Loading branch information
ear-dev committed Mar 17, 2020
2 parents 29bb6d6 + 5f65c35 commit b16243b
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/mentions-flextab/client/actionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Meteor.startup(function() {
action() {
const { msg: message } = messageArgs(this);
if (window.matchMedia('(max-width: 500px)').matches) {
Template.currentData().instance.tabBar.close();
Template.instance().tabBar.close();
}
RoomHistoryManager.getSurroundingMessages(message, 50);
},
Expand Down
8 changes: 4 additions & 4 deletions app/message-pin/client/actionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import toastr from 'toastr';

import { RoomHistoryManager, MessageAction } from '../../ui-utils';
import { messageArgs } from '../../ui-utils/client/lib/messageArgs';
import { handleError } from '../../utils';
import { handleError, isMobile } from '../../utils';
import { settings } from '../../settings';
import { hasAtLeastOnePermission } from '../../authorization';

Expand Down Expand Up @@ -68,12 +68,12 @@ Meteor.startup(function() {
action() {
const { msg: message } = messageArgs(this);
if (window.matchMedia('(max-width: 500px)').matches) {
Template.currentData().instance.tabBar.close();
Template.instance().tabBar.close();
}
return RoomHistoryManager.getSurroundingMessages(message, 50);
},
condition({ msg, subscription }) {
return msg.pinned && !!subscription;
condition({ subscription }) {
return !!subscription && !isMobile();
},
order: 100,
group: 'menu',
Expand Down
2 changes: 1 addition & 1 deletion app/message-star/client/actionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Meteor.startup(function() {
action() {
const { msg: message } = messageArgs(this);
if (window.matchMedia('(max-width: 500px)').matches) {
Template.currentData().instance.tabBar.close();
Template.instance().tabBar.close();
}
RoomHistoryManager.getSurroundingMessages(message, 50);
},
Expand Down
2 changes: 1 addition & 1 deletion app/search/client/provider/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Meteor.startup(function() {
// RocketChat.MessageAction.hideDropDown();

if (window.matchMedia('(max-width: 500px)').matches) {
Template.currentData().instance.tabBar.close();
Template.instance().tabBar.close();
}

window.setTimeout(() => {
Expand Down
3 changes: 1 addition & 2 deletions app/theme/client/imports/components/sidebar/rooms-list.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@
@media (width <= 500px) {
.rooms-list {
&__type {
padding: 0 var(--sidebar-small-default-padding) 1rem var(--sidebar-small-default-padding);

font-size: var(--rooms-list-title-text-size-mobile);
padding: 0 var(--sidebar-small-default-padding) 1rem var(--sidebar-small-default-padding);
}

&__empty-room {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
width: 200px;

& .rc-input__element {
background-color: var(--sidebar-background);
border-color: #81868d;
border-radius: 15px;

color: var(--color-white);
border-color: var(--rc-color-primary-dark);
background-color: var(--rc-color-primary-darkest);
Expand Down Expand Up @@ -163,7 +167,6 @@
@media (width <= 500px) {
.sidebar__header {
padding: var(--sidebar-small-default-padding);

&-thumb {
flex: 0 0 var(--sidebar-account-thumb-size-mobile);

Expand Down
2 changes: 2 additions & 0 deletions app/ui-utils/client/lib/RoomHistoryManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,13 @@ export const RoomHistoryManager = new class {
}
const room = this.getRoom(message.rid);
room.isLoading.set(true);
ChatMessage.remove({ rid: message.rid });

let typeName = undefined;

const subscription = ChatSubscription.findOne({ rid: message.rid });
if (subscription) {
// const { ls } = subscription;
typeName = subscription.t + subscription.name;
} else {
const curRoomDoc = ChatRoom.findOne({ _id: message.rid });
Expand Down
4 changes: 1 addition & 3 deletions app/ui/client/views/app/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ const showMessageActions = (e, outerContext) => {
};

const mountPopover = (e, i, outerContext) => {
let context = $(e.target).parents('.message').data('context')
|| ($(e.target).parents('.message').hasClass('mentions') && 'mentions');

let context = $(e.target).parents('.message').data('context');
if (!context) {
context = 'message';
}
Expand Down
6 changes: 3 additions & 3 deletions client/startup/offlineMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const retainMessages = (rid, messages) => {
const roomMsgs = messages.filter((msg) => rid === msg.rid);
const limit = parseInt(getConfig('roomListLimit')) || 50;
const retain = sortBy(roomMsgs.filter((msg) => !msg.temp), 'ts').reverse().slice(0, limit);
retain.push(...roomMsgs.filter((msg) => msg.temp));
retain.push(...messages.filter((msg) => rid === msg.rid && msg.temp));
return retain;
};

Expand All @@ -141,12 +141,12 @@ function clearOldMessages({ records: messages, ...value }) {
});
}

const cleanMessagesAtStartup = () => {
const clearOldMessageAtStartup = () => {
localforage.getItem('chatMessage').then((value) => {
if (value && value.records) {
clearOldMessages(value);
}
});
};

callbacks.add('afterMainReady', cleanMessagesAtStartup, callbacks.priority.MEDIUM, 'cleanMessagesAtStartup');
callbacks.add('afterMainReady', clearOldMessageAtStartup, callbacks.priority.LOW, 'clearOldMessageAtStartup');

0 comments on commit b16243b

Please sign in to comment.