|
|
|
@ -2,11 +2,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
define('forum/chats/messages', [
|
|
|
|
|
'components', 'translator', 'benchpress', 'hooks',
|
|
|
|
|
'bootbox', 'alerts', 'messages', 'api', 'forum/topic/images',
|
|
|
|
|
'components', 'hooks', 'bootbox', 'alerts',
|
|
|
|
|
'messages', 'api', 'forum/topic/images',
|
|
|
|
|
], function (
|
|
|
|
|
components, translator, Benchpress, hooks,
|
|
|
|
|
bootbox, alerts, messagesModule, api, images
|
|
|
|
|
components, hooks, bootbox, alerts, messagesModule, api, images
|
|
|
|
|
) {
|
|
|
|
|
const messages = {};
|
|
|
|
|
|
|
|
|
@ -106,17 +105,15 @@ define('forum/chats/messages', [
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
messages.parseMessage = function (data, callback) {
|
|
|
|
|
function done(html) {
|
|
|
|
|
translator.translate(html, translated => callback($(translated)));
|
|
|
|
|
}
|
|
|
|
|
const tplData = {
|
|
|
|
|
messages: data,
|
|
|
|
|
isAdminOrGlobalMod: app.user.isAdmin || app.user.isGlobalMod,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
if (Array.isArray(data)) {
|
|
|
|
|
Benchpress.render('partials/chats/messages', tplData).then(done);
|
|
|
|
|
app.parseAndTranslate('partials/chats/messages', tplData).then(callback);
|
|
|
|
|
} else {
|
|
|
|
|
Benchpress.render('partials/chats/' + (data.system ? 'system-message' : 'message'), tplData).then(done);
|
|
|
|
|
app.parseAndTranslate('partials/chats/' + (data.system ? 'system-message' : 'message'), tplData).then(callback);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -256,16 +253,14 @@ define('forum/chats/messages', [
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
messages.delete = function (messageId, roomId) {
|
|
|
|
|
translator.translate('[[modules:chat.delete_message_confirm]]', function (translated) {
|
|
|
|
|
bootbox.confirm(translated, function (ok) {
|
|
|
|
|
if (!ok) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
bootbox.confirm('[[modules:chat.delete_message_confirm]]', function (ok) {
|
|
|
|
|
if (!ok) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
api.del(`/chats/${roomId}/messages/${messageId}`, {}).then(() => {
|
|
|
|
|
components.get('chat/message', messageId).toggleClass('deleted', true);
|
|
|
|
|
}).catch(alerts.error);
|
|
|
|
|
});
|
|
|
|
|
api.del(`/chats/${roomId}/messages/${messageId}`, {}).then(() => {
|
|
|
|
|
components.get('chat/message', messageId).toggleClass('deleted', true);
|
|
|
|
|
}).catch(alerts.error);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|