mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
remove since properly
This commit is contained in:
@@ -61,8 +61,8 @@
|
||||
"nodebb-plugin-spam-be-gone": "0.4.10",
|
||||
"nodebb-rewards-essentials": "0.0.9",
|
||||
"nodebb-theme-lavender": "3.0.14",
|
||||
"nodebb-theme-persona": "4.1.55",
|
||||
"nodebb-theme-vanilla": "5.1.36",
|
||||
"nodebb-theme-persona": "4.1.56",
|
||||
"nodebb-theme-vanilla": "5.1.37",
|
||||
"nodebb-widget-essentials": "2.0.11",
|
||||
"nodemailer": "2.0.0",
|
||||
"nodemailer-sendmail-transport": "1.0.0",
|
||||
|
||||
@@ -281,7 +281,7 @@ app.cacheBuster = null;
|
||||
if (chat.modalExists(roomId)) {
|
||||
loadAndCenter(chat.getModal(roomId));
|
||||
} else {
|
||||
socket.emit('modules.chats.loadRoom', {roomId: roomId}, function(err, roomData) {
|
||||
socket.emit('modules.chats.loadRoom', {roomId: roomId, uid: uid || app.user.uid}, function(err, roomData) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -154,131 +154,117 @@ define('chat', [
|
||||
return $('#chat-modal-' + roomId).length !== 0;
|
||||
};
|
||||
|
||||
function checkStatus(chatModal) {
|
||||
socket.emit('user.checkStatus', chatModal.attr('touid'), function(err, status) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
module.createModal = function(data, callback) {
|
||||
app.parseAndTranslate('chat', data, function(chatModal) {
|
||||
|
||||
var uuid = utils.generateUUID();
|
||||
var dragged = false;
|
||||
|
||||
chatModal.attr('id', 'chat-modal-' + data.roomId);
|
||||
chatModal.attr('roomId', data.roomId);
|
||||
chatModal.attr('intervalId', 0);
|
||||
chatModal.attr('UUID', uuid);
|
||||
chatModal.css('position', 'fixed');
|
||||
chatModal.css('zIndex', 100);
|
||||
chatModal.appendTo($('body'));
|
||||
chatModal.find('.timeago').timeago();
|
||||
module.center(chatModal);
|
||||
|
||||
app.loadJQueryUI(function() {
|
||||
chatModal.find('.modal-content').resizable({
|
||||
handles: 'n, e, s, w, se',
|
||||
minHeight: 250,
|
||||
minWidth: 400
|
||||
});
|
||||
|
||||
chatModal.find('.modal-content').on('resize', function(event, ui) {
|
||||
if (ui.originalSize.height === ui.size.height) {
|
||||
return;
|
||||
}
|
||||
|
||||
chatModal.find('.chat-content').css('height', module.calculateChatListHeight(chatModal));
|
||||
});
|
||||
|
||||
chatModal.draggable({
|
||||
start:function() {
|
||||
module.bringModalToTop(chatModal);
|
||||
},
|
||||
stop:function() {
|
||||
chatModal.find('#chat-message-input').focus();
|
||||
},
|
||||
distance: 10,
|
||||
handle: '.modal-header'
|
||||
});
|
||||
});
|
||||
|
||||
chatModal.find('#chat-close-btn').on('click', function() {
|
||||
module.close(chatModal);
|
||||
});
|
||||
|
||||
function gotoChats() {
|
||||
var text = components.get('chat/input').val();
|
||||
$(window).one('action:ajaxify.end', function() {
|
||||
components.get('chat/input').val(text);
|
||||
});
|
||||
|
||||
ajaxify.go('user/' + app.user.userslug + '/chats/' + chatModal.attr('roomId'));
|
||||
module.close(chatModal);
|
||||
}
|
||||
|
||||
app.updateUserStatus(chatModal.find('[component="user/status"]'), status);
|
||||
});
|
||||
}
|
||||
chatModal.find('.modal-header').on('dblclick', gotoChats);
|
||||
chatModal.find('button[data-action="maximize"]').on('click', gotoChats);
|
||||
|
||||
module.createModal = function(data, callback) {
|
||||
templates.parse('chat', data, function(chatTpl) {
|
||||
translator.translate(chatTpl, function (chatTpl) {
|
||||
chatModal.on('click', function() {
|
||||
module.bringModalToTop(chatModal);
|
||||
|
||||
var chatModal = $(chatTpl),
|
||||
uuid = utils.generateUUID(),
|
||||
if (dragged) {
|
||||
dragged = false;
|
||||
|
||||
chatModal.attr('id', 'chat-modal-' + data.roomId);
|
||||
chatModal.attr('roomId', data.roomId);
|
||||
chatModal.attr('intervalId', 0);
|
||||
chatModal.attr('UUID', uuid);
|
||||
chatModal.css('position', 'fixed');
|
||||
chatModal.css('zIndex', 100);
|
||||
chatModal.appendTo($('body'));
|
||||
module.center(chatModal);
|
||||
|
||||
app.loadJQueryUI(function() {
|
||||
chatModal.find('.modal-content').resizable({
|
||||
handles: 'n, e, s, w, se',
|
||||
minHeight: 250,
|
||||
minWidth: 400
|
||||
});
|
||||
|
||||
chatModal.find('.modal-content').on('resize', function(event, ui) {
|
||||
if (ui.originalSize.height === ui.size.height) {
|
||||
return;
|
||||
}
|
||||
|
||||
chatModal.find('.chat-content').css('height', module.calculateChatListHeight(chatModal));
|
||||
});
|
||||
|
||||
chatModal.draggable({
|
||||
start:function() {
|
||||
module.bringModalToTop(chatModal);
|
||||
},
|
||||
stop:function() {
|
||||
chatModal.find('#chat-message-input').focus();
|
||||
},
|
||||
distance: 10,
|
||||
handle: '.modal-header'
|
||||
});
|
||||
});
|
||||
|
||||
chatModal.find('#chat-close-btn').on('click', function() {
|
||||
module.close(chatModal);
|
||||
});
|
||||
|
||||
function gotoChats() {
|
||||
var text = components.get('chat/input').val();
|
||||
$(window).one('action:ajaxify.end', function() {
|
||||
components.get('chat/input').val(text);
|
||||
});
|
||||
|
||||
ajaxify.go('user/' + app.user.userslug + '/chats/' + chatModal.attr('roomId'));
|
||||
module.close(chatModal);
|
||||
}
|
||||
|
||||
chatModal.find('.modal-header').on('dblclick', gotoChats);
|
||||
chatModal.find('button[data-action="maximize"]').on('click', gotoChats);
|
||||
|
||||
chatModal.on('click', function() {
|
||||
module.bringModalToTop(chatModal);
|
||||
|
||||
if (dragged) {
|
||||
dragged = false;
|
||||
}
|
||||
});
|
||||
|
||||
chatModal.on('mousemove', function(e) {
|
||||
if (e.which === 1) {
|
||||
dragged = true;
|
||||
}
|
||||
});
|
||||
|
||||
chatModal.on('mousemove keypress click', function() {
|
||||
if (newMessage) {
|
||||
socket.emit('modules.chats.markRead', data.roomId);
|
||||
newMessage = false;
|
||||
}
|
||||
});
|
||||
|
||||
Chats.addEditDeleteHandler(chatModal.find('[component="chat/messages"]'), data.roomId);
|
||||
|
||||
chatModal.find('[component="chat/controlsToggle"]').on('click', function() {
|
||||
var messagesEl = chatModal.find('[component="chat/messages"]');
|
||||
|
||||
chatModal.find('[component="chat/controls"]').toggle();
|
||||
messagesEl.css('height', module.calculateChatListHeight(chatModal));
|
||||
});
|
||||
|
||||
Chats.addRenameHandler(chatModal.attr('roomId'), chatModal.find('[component="chat/room/name"]'));
|
||||
|
||||
Chats.addSendHandlers(chatModal.attr('roomId'), chatModal.find('#chat-message-input'), chatModal.find('#chat-message-send-btn'));
|
||||
|
||||
Chats.createTagsInput(chatModal.find('.users-tag-input'), data);
|
||||
Chats.createAutoComplete(chatModal.find('[component="chat/input"]'));
|
||||
|
||||
Chats.addScrollHandler(chatModal.attr('roomId'), data.uid, chatModal.find('.chat-content'));
|
||||
|
||||
checkStatus(chatModal);
|
||||
|
||||
taskbar.push('chat', chatModal.attr('UUID'), {
|
||||
title: data.users.length ? data.users[0].username : '',
|
||||
roomId: data.roomId,
|
||||
icon: 'fa-comment',
|
||||
state: ''
|
||||
});
|
||||
|
||||
$(window).trigger('action:chat.loaded', chatModal);
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback(chatModal);
|
||||
}
|
||||
});
|
||||
|
||||
chatModal.on('mousemove', function(e) {
|
||||
if (e.which === 1) {
|
||||
dragged = true;
|
||||
}
|
||||
});
|
||||
|
||||
chatModal.on('mousemove keypress click', function() {
|
||||
if (newMessage) {
|
||||
socket.emit('modules.chats.markRead', data.roomId);
|
||||
newMessage = false;
|
||||
}
|
||||
});
|
||||
|
||||
Chats.addEditDeleteHandler(chatModal.find('[component="chat/messages"]'), data.roomId);
|
||||
|
||||
chatModal.find('[component="chat/controlsToggle"]').on('click', function() {
|
||||
var messagesEl = chatModal.find('[component="chat/messages"]');
|
||||
|
||||
chatModal.find('[component="chat/controls"]').toggle();
|
||||
messagesEl.css('height', module.calculateChatListHeight(chatModal));
|
||||
});
|
||||
|
||||
Chats.addRenameHandler(chatModal.attr('roomId'), chatModal.find('[component="chat/room/name"]'));
|
||||
|
||||
Chats.addSendHandlers(chatModal.attr('roomId'), chatModal.find('#chat-message-input'), chatModal.find('#chat-message-send-btn'));
|
||||
|
||||
Chats.createTagsInput(chatModal.find('.users-tag-input'), data);
|
||||
Chats.createAutoComplete(chatModal.find('[component="chat/input"]'));
|
||||
|
||||
Chats.addScrollHandler(chatModal.attr('roomId'), data.uid, chatModal.find('.chat-content'));
|
||||
|
||||
taskbar.push('chat', chatModal.attr('UUID'), {
|
||||
title: data.users.length ? data.users[0].username : '',
|
||||
roomId: data.roomId,
|
||||
icon: 'fa-comment',
|
||||
state: ''
|
||||
});
|
||||
|
||||
$(window).trigger('action:chat.loaded', chatModal);
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback(chatModal);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ chatsController.get = function(req, res, callback) {
|
||||
callerUid: req.uid,
|
||||
uid: uid,
|
||||
roomId: req.params.roomid,
|
||||
since: 'recent',
|
||||
isNew: false
|
||||
}),
|
||||
room: async.apply(messaging.getRoomData, req.params.roomid)
|
||||
|
||||
@@ -22,13 +22,6 @@ var userNotifications = require('./user/notifications');
|
||||
require('./messaging/unread')(Messaging);
|
||||
require('./messaging/notifications')(Messaging);
|
||||
|
||||
var terms = {
|
||||
day: 86400000,
|
||||
week: 604800000,
|
||||
month: 2592000000,
|
||||
threemonths: 7776000000
|
||||
};
|
||||
|
||||
Messaging.getMessageField = function(mid, field, callback) {
|
||||
Messaging.getMessageFields(mid, [field], function(err, fields) {
|
||||
callback(err, fields ? fields[field] : null);
|
||||
@@ -50,18 +43,11 @@ var userNotifications = require('./user/notifications');
|
||||
Messaging.getMessages = function(params, callback) {
|
||||
var uid = params.uid;
|
||||
var roomId = params.roomId;
|
||||
var since = params.since;
|
||||
var isNew = params.isNew || false;
|
||||
var start = params.hasOwnProperty('start') ? params.start : 0;
|
||||
var count = params.count || 250;
|
||||
var stop = parseInt(start, 10) + ((params.count || 50) - 1);
|
||||
var markRead = params.markRead || true;
|
||||
|
||||
var min = params.count ? 0 : Date.now() - (terms[since] || terms.day);
|
||||
|
||||
if (since === 'recent') {
|
||||
count = 50;
|
||||
min = 0;
|
||||
}
|
||||
var indices = {};
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
@@ -71,7 +57,7 @@ var userNotifications = require('./user/notifications');
|
||||
if (!canGet) {
|
||||
return callback(null, null);
|
||||
}
|
||||
db.getSortedSetRevRangeByScore('uid:' + uid + ':chat:room:' + roomId + ':mids', start, count, '+inf', min, next);
|
||||
db.getSortedSetRevRange('uid:' + uid + ':chat:room:' + roomId + ':mids', start, stop, next);
|
||||
},
|
||||
function(mids, next) {
|
||||
if (!Array.isArray(mids) || !mids.length) {
|
||||
|
||||
@@ -115,11 +115,18 @@ SocketModules.chats.loadRoom = function(socket, data, callback) {
|
||||
|
||||
async.parallel({
|
||||
roomData: async.apply(Messaging.getRoomData, data.roomId),
|
||||
users: async.apply(Messaging.getUsersInRoom, data.roomId, 0, -1)
|
||||
users: async.apply(Messaging.getUsersInRoom, data.roomId, 0, -1),
|
||||
messages: async.apply(Messaging.getMessages, {
|
||||
callerUid: socket.uid,
|
||||
uid: data.uid || socket.uid,
|
||||
roomId: data.roomId,
|
||||
isNew: false
|
||||
}),
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
results.roomData.users = results.users;
|
||||
results.roomData.messages = results.messages;
|
||||
results.roomData.groupChat = results.roomData.hasOwnProperty('groupChat') ? results.roomData.groupChat : results.users.length > 2;
|
||||
results.roomData.isOwner = parseInt(results.roomData.owner, 10) === socket.uid;
|
||||
results.roomData.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
|
||||
@@ -312,10 +319,6 @@ SocketModules.chats.getMessages = function(socket, data, callback) {
|
||||
markRead: false
|
||||
};
|
||||
|
||||
if (data.hasOwnProperty('since')) {
|
||||
params.since = data.since;
|
||||
}
|
||||
|
||||
if (data.hasOwnProperty('markRead')) {
|
||||
params.markRead = data.markRead;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user