mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Performance: Inbox Paging / loading (#11157)
* load messages per conversation * only sort ones in ui * add contributor to message * fix correct message layout/message * mugenScroll on chatMessages * fix lint, no mugen-scroll, use own scroll handler * fix height / margin of modal + use button to load more * fix tests * user data from inbox * style "load earlier messages" * move mapMessage to the inbox api result / extract sentMessage of members-api-controller * fix test back * fix test * keep last scroll position * just set the Id of the returned message instead of all other properties * fix add new messages (buttons were hidden) + load more * item-mounted debounce to trigger the re-scrolling
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
} from '../../libs/email';
|
||||
import { sendNotification as sendPushNotification } from '../../libs/pushNotifications';
|
||||
import { achievements } from '../../../../website/common/';
|
||||
import {sentMessage} from '../../libs/inbox';
|
||||
|
||||
let api = {};
|
||||
|
||||
@@ -633,6 +634,7 @@ api.sendPrivateMessage = {
|
||||
|
||||
const sender = res.locals.user;
|
||||
const message = req.body.message;
|
||||
|
||||
const receiver = await User.findById(req.body.toUserId).exec();
|
||||
if (!receiver) throw new NotFound(res.t('userNotFound'));
|
||||
if (!receiver.flags.verifiedUsername) delete receiver.auth.local.username;
|
||||
@@ -640,26 +642,7 @@ api.sendPrivateMessage = {
|
||||
const objections = sender.getObjectionsToInteraction('send-private-message', receiver);
|
||||
if (objections.length > 0 && !sender.isAdmin()) throw new NotAuthorized(res.t(objections[0]));
|
||||
|
||||
const messageSent = await sender.sendMessage(receiver, { receiverMsg: message });
|
||||
|
||||
if (receiver.preferences.emailNotifications.newPM !== false) {
|
||||
sendTxnEmail(receiver, 'new-pm', [
|
||||
{name: 'SENDER', content: getUserInfo(sender, ['name']).name},
|
||||
]);
|
||||
}
|
||||
|
||||
if (receiver.preferences.pushNotifications.newPM !== false) {
|
||||
sendPushNotification(
|
||||
receiver,
|
||||
{
|
||||
title: res.t('newPM'),
|
||||
message: res.t('newPMInfo', {name: getUserInfo(sender, ['name']).name, message}),
|
||||
identifier: 'newPM',
|
||||
category: 'newPM',
|
||||
payload: {replyTo: sender._id},
|
||||
}
|
||||
);
|
||||
}
|
||||
const messageSent = await sentMessage(sender, receiver, message, res.t);
|
||||
|
||||
res.respond(200, {message: messageSent});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user