Skip to content

Commit

Permalink
fix: get surrounding message method
Browse files Browse the repository at this point in the history
  • Loading branch information
filipemarins committed Jul 4, 2022
1 parent 076b03c commit de8d324
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/meteor/app/ui-utils/client/lib/RoomHistoryManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,14 @@ export const RoomHistoryManager = new (class extends Emitter {
const surroundingMessage = ChatMessage.findOne({ _id: message._id, _hidden: { $ne: true } });

if (surroundingMessage) {
const msgElement = $(`[data-id='${message._id}']`, w);
await waitUntilWrapperExists(`[data-id='${message._id}']`);
const wrapper = $('.messages-box .wrapper');
const msgElement = $(`[data-id='${message._id}']`, wrapper);

if (msgElement.length === 0) {
return;
}

const wrapper = $('.messages-box .wrapper');
const pos = wrapper.scrollTop() + msgElement.offset().top - wrapper.height() / 2;
wrapper.animate(
{
Expand All @@ -337,6 +338,7 @@ export const RoomHistoryManager = new (class extends Emitter {

const room = this.getRoom(message.rid);
room.isLoading.set(true);
room.hasMore.set(false);
let typeName = undefined;

const subscription = ChatSubscription.findOne({ rid: message.rid });
Expand All @@ -352,7 +354,7 @@ export const RoomHistoryManager = new (class extends Emitter {
if (!result || !result.messages) {
return;
}
RoomHistoryManager.clear(message.rid);

for (const msg of Array.from(result.messages)) {
if (msg.t !== 'command') {
upsertMessage({ msg, subscription });
Expand Down

0 comments on commit de8d324

Please sign in to comment.