fix: dont show chat upload btn if maxFileSize is 0, #12926

This commit is contained in:
Barış Soner Uşaklı
2024-11-21 10:05:16 -05:00
parent 8f944e9325
commit 1412585856
4 changed files with 10 additions and 3 deletions

View File

@@ -98,7 +98,7 @@
"multiparty": "4.2.3", "multiparty": "4.2.3",
"nconf": "0.12.1", "nconf": "0.12.1",
"nodebb-plugin-2factor": "7.5.6", "nodebb-plugin-2factor": "7.5.6",
"nodebb-plugin-composer-default": "10.2.42", "nodebb-plugin-composer-default": "10.2.43",
"nodebb-plugin-dbsearch": "6.2.5", "nodebb-plugin-dbsearch": "6.2.5",
"nodebb-plugin-emoji": "5.1.15", "nodebb-plugin-emoji": "5.1.15",
"nodebb-plugin-emoji-android": "4.0.0", "nodebb-plugin-emoji-android": "4.0.0",

View File

@@ -171,6 +171,8 @@ get:
type: number type: number
canReply: canReply:
type: boolean type: boolean
canUpload:
type: boolean
groupChat: groupChat:
type: boolean type: boolean
usernames: usernames:

View File

@@ -67,8 +67,11 @@ chatsController.get = async function (req, res, next) {
room.title = room.roomName || room.usernames || '[[pages:chats]]'; room.title = room.roomName || room.usernames || '[[pages:chats]]';
room.bodyClasses = ['chat-loaded']; room.bodyClasses = ['chat-loaded'];
room.canViewInfo = await privileges.global.can('view:users:info', uid); const [canViewInfo, canUploadImage, canUploadFile] = await privileges.global.can([
'view:users:info', 'upload:post:image', 'upload:post:file',
], uid);
room.canViewInfo = canViewInfo;
room.canUpload = (canUploadImage || canUploadFile) && (meta.config.maximumFileSize > 0 || room.isAdmin);
res.render('chats', { res.render('chats', {
...payload, ...payload,
...room, ...room,

View File

@@ -3,7 +3,9 @@
<div component="chat/composer/replying-to-text"></div> <button component="chat/composer/replying-to-cancel" class="btn btn-ghost btn-sm px-2 py-1"><i class="fa fa-times"></i></button> <div component="chat/composer/replying-to-text"></div> <button component="chat/composer/replying-to-cancel" class="btn btn-ghost btn-sm px-2 py-1"><i class="fa fa-times"></i></button>
</div> </div>
<div class="w-100 flex-grow-1 flex-nowrap position-relative d-flex rounded-2 border border-secondary p-1 align-items-end"> <div class="w-100 flex-grow-1 flex-nowrap position-relative d-flex rounded-2 border border-secondary p-1 align-items-end">
{{{ if canUpload }}}
<button component="chat/upload/button" class="btn btn-ghost btn-sm d-flex p-2" type="button" title="[[global:upload]]" data-bs-toggle="tooltip"><i class="fa fa-fw fa-upload"></i></button> <button component="chat/upload/button" class="btn btn-ghost btn-sm d-flex p-2" type="button" title="[[global:upload]]" data-bs-toggle="tooltip"><i class="fa fa-fw fa-upload"></i></button>
{{{ end }}}
<div class="flex-grow-1 align-self-center"> <div class="flex-grow-1 align-self-center">
<textarea component="chat/input" placeholder="{{{ if roomName }}}[[modules:chat.placeholder.message-room, {roomName}]]{{{ else }}}[[modules:chat.placeholder.mobile]]{{{ end }}}" class="bg-transparent text-body form-control chat-input mousetrap rounded-0 border-0 shadow-none px-1 py-0" style="min-height: 1.5rem;height:0;max-height:30vh;resize:none;"></textarea> <textarea component="chat/input" placeholder="{{{ if roomName }}}[[modules:chat.placeholder.message-room, {roomName}]]{{{ else }}}[[modules:chat.placeholder.mobile]]{{{ end }}}" class="bg-transparent text-body form-control chat-input mousetrap rounded-0 border-0 shadow-none px-1 py-0" style="min-height: 1.5rem;height:0;max-height:30vh;resize:none;"></textarea>
</div> </div>