fix mobile mobile bar

fix user count if user just joined
isekai-main
Barış Soner Uşaklı 2 years ago
parent 9149a9a2cb
commit 4782764aee

@ -50,7 +50,7 @@ define('forum/chats', [
recentChats.init(); recentChats.init();
Chats.addEventListeners(); Chats.addEventListeners();
Chats.setActive(); Chats.setActive(ajaxify.data.roomId);
if (env === 'md' || env === 'lg' || env === 'xl' || env === 'xxl') { if (env === 'md' || env === 'lg' || env === 'xl' || env === 'xxl') {
Chats.addHotkeys(); Chats.addHotkeys();
@ -437,20 +437,20 @@ define('forum/chats', [
}).catch(alerts.error); }).catch(alerts.error);
}; };
Chats.switchChat = function (roomid) { Chats.switchChat = function (roomId) {
// Allow empty arg for return to chat list/close chat // Allow empty arg for return to chat list/close chat
if (!roomid) { if (!roomId) {
roomid = ''; roomId = '';
} }
Chats.destroyAutoComplete(ajaxify.data.roomId); Chats.destroyAutoComplete(ajaxify.data.roomId);
socket.emit('modules.chats.leave', ajaxify.data.roomId); socket.emit('modules.chats.leave', ajaxify.data.roomId);
const url = 'user/' + ajaxify.data.userslug + '/chats/' + roomid + window.location.search; const url = 'user/' + ajaxify.data.userslug + '/chats/' + roomId + window.location.search;
if (!self.fetch) { if (!self.fetch) {
return ajaxify.go(url); return ajaxify.go(url);
} }
const params = new URL(document.location).searchParams; const params = new URL(document.location).searchParams;
params.set('switch', 1); params.set('switch', 1);
const dataUrl = `${config.relative_path}/api/user/${ajaxify.data.userslug}/chats/${roomid}?${params.toString()}`; const dataUrl = `${config.relative_path}/api/user/${ajaxify.data.userslug}/chats/${roomId}?${params.toString()}`;
fetch(dataUrl, { credentials: 'include' }) fetch(dataUrl, { credentials: 'include' })
.then(async function (response) { .then(async function (response) {
if (!response.ok) { if (!response.ok) {
@ -462,10 +462,10 @@ define('forum/chats', [
mainWrapper.html(html); mainWrapper.html(html);
chatNavWrapper = $('[component="chat/nav-wrapper"]'); chatNavWrapper = $('[component="chat/nav-wrapper"]');
html.find('.timeago').timeago(); html.find('.timeago').timeago();
ajaxify.data = { ...ajaxify.data, ...payload, roomId: roomid }; ajaxify.data = { ...ajaxify.data, ...payload, roomId: roomId };
$('body').addClass(ajaxify.data.bodyClass); $('body').toggleClass('chat-loaded', !!roomId);
mainWrapper.find('[data-bs-toggle="tooltip"]').tooltip(); mainWrapper.find('[data-bs-toggle="tooltip"]').tooltip();
Chats.setActive(); Chats.setActive(roomId);
Chats.addEventListeners(); Chats.addEventListeners();
hooks.fire('action:chat.loaded', $('.chats-full')); hooks.fire('action:chat.loaded', $('.chats-full'));
messages.scrollToBottom(mainWrapper.find('.expanded-chat ul.chat-content')); messages.scrollToBottom(mainWrapper.find('.expanded-chat ul.chat-content'));
@ -566,24 +566,24 @@ define('forum/chats', [
unreadCountEl.toggleClass('hidden', count <= 0).text(countText).attr('data-count', count); unreadCountEl.toggleClass('hidden', count <= 0).text(countText).attr('data-count', count);
}; };
Chats.setActive = function () { Chats.setActive = function (roomId) {
chatNavWrapper.find('[data-roomid]').removeClass('active'); chatNavWrapper.find('[data-roomid]').removeClass('active');
if (ajaxify.data.roomId) { if (roomId) {
socket.emit('modules.chats.enter', ajaxify.data.roomId); socket.emit('modules.chats.enter', roomId);
const chatEl = chatNavWrapper.find(`[data-roomid="${ajaxify.data.roomId}"]`); const chatEl = chatNavWrapper.find(`[data-roomid="${roomId}"]`);
chatEl.addClass('active'); chatEl.addClass('active');
if (chatEl.hasClass('unread')) { if (chatEl.hasClass('unread')) {
api.del(`/chats/${ajaxify.data.roomId}/state`, {}); api.del(`/chats/${roomId}/state`, {});
chatEl.removeClass('unread'); chatEl.removeClass('unread');
} }
if (!utils.isMobile()) { if (!utils.isMobile()) {
$('.expanded-chat [component="chat/input"]').focus(); $('.expanded-chat [component="chat/input"]').focus();
} }
messages.updateTextAreaHeight($(`[component="chat/messages"][data-roomid="${ajaxify.data.roomId}"]`)); messages.updateTextAreaHeight($(`[component="chat/messages"][data-roomid="${roomId}"]`));
} }
chatNavWrapper.attr('data-loaded', ajaxify.data.roomId ? '1' : '0'); chatNavWrapper.attr('data-loaded', roomId ? '1' : '0');
}; };
return Chats; return Chats;

@ -394,6 +394,7 @@ module.exports = function (Messaging) {
// add user to public room onload // add user to public room onload
if (room.public && !inRoom) { if (room.public && !inRoom) {
await addUidsToRoom([uid], roomId); await addUidsToRoom([uid], roomId);
room.userCount += 1;
} }
const [canReply, users, messages, isAdmin, isGlobalMod, settings, isOwner] = await Promise.all([ const [canReply, users, messages, isAdmin, isGlobalMod, settings, isOwner] = await Promise.all([

Loading…
Cancel
Save