Improve attachment error handling

This commit is contained in:
Maximilian Mader 2020-11-02 21:27:08 +01:00
parent a0557e3178
commit 09892db6f1
Signed by: Max
GPG Key ID: F71D56A3151C4FB3
3 changed files with 20 additions and 5 deletions

View File

@ -5,7 +5,7 @@
* Use of this software is governed by the Business Source License
* included in the LICENSE file.
*
* Change Date: 2024-11-01
* Change Date: 2024-11-02
*
* On the date above, in accordance with the Business Source
* License, use of this software will be governed by version 2
@ -318,6 +318,8 @@ class MessageAction extends \wcf\data\AbstractDatabaseObjectAction {
$user = new \chat\data\user\User(WCF::getUser());
if (!$user->isInRoom($room)) throw new PermissionDeniedException();
if (!$room->canWritePublicly(null, $reason)) throw $reason;
$this->readString('tmpHash');
}
@ -337,7 +339,7 @@ class MessageAction extends \wcf\data\AbstractDatabaseObjectAction {
foreach ($attachments as $attachment) {
$attachmentIDs[] = $attachment->attachmentID;
}
$processor = new \wcf\system\html\input\HtmlInputProcessor();
$processor->process(implode(' ', array_map(function ($attachmentID) {
return '[attach='.$attachmentID.',none,true][/attach]';

View File

@ -4,7 +4,7 @@
* Use of this software is governed by the Business Source License
* included in the LICENSE file.
*
* Change Date: 2024-11-01
* Change Date: 2024-11-02
*
* On the date above, in accordance with the Business Source
* License, use of this software will be governed by version 2
@ -570,6 +570,11 @@ $chatEmbedMaxWidth: 400px;
.attachmentPreview {
text-align: center;
.error {
margin-top: 0;
margin-bottom: 20px;
}
img {
margin-left: auto !important;
margin-right: auto !important;

View File

@ -4,7 +4,7 @@
* Use of this software is governed by the Business Source License
* included in the LICENSE file.
*
* Change Date: 2024-11-01
* Change Date: 2024-11-02
*
* On the date above, in accordance with the Business Source
* License, use of this software will be governed by version 2
@ -177,8 +177,16 @@ define([
this.deleteOnClose = false
this.closeDialog()
} catch (error) {
// TODO: Error handling
console.error(error)
let container = this._target.querySelector('.error')
if (!container) {
container = document.createElement('div')
container.classList.add('error')
this._target.insertBefore(container, this._target.firstChild)
}
container.innerText = error.message
Dialog.rebuild(DIALOG_CONTAINER_ID)
}
}