1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-21 21:30:08 +00:00

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 * Use of this software is governed by the Business Source License
* included in the LICENSE file. * 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 * On the date above, in accordance with the Business Source
* License, use of this software will be governed by version 2 * License, use of this software will be governed by version 2
@ -318,6 +318,8 @@ public function validatePushAttachment() {
$user = new \chat\data\user\User(WCF::getUser()); $user = new \chat\data\user\User(WCF::getUser());
if (!$user->isInRoom($room)) throw new PermissionDeniedException(); if (!$user->isInRoom($room)) throw new PermissionDeniedException();
if (!$room->canWritePublicly(null, $reason)) throw $reason;
$this->readString('tmpHash'); $this->readString('tmpHash');
} }

View File

@ -4,7 +4,7 @@
* Use of this software is governed by the Business Source License * Use of this software is governed by the Business Source License
* included in the LICENSE file. * 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 * On the date above, in accordance with the Business Source
* License, use of this software will be governed by version 2 * License, use of this software will be governed by version 2
@ -570,6 +570,11 @@ #tpl_chat_log {
.attachmentPreview { .attachmentPreview {
text-align: center; text-align: center;
.error {
margin-top: 0;
margin-bottom: 20px;
}
img { img {
margin-left: auto !important; margin-left: auto !important;
margin-right: auto !important; margin-right: auto !important;

View File

@ -4,7 +4,7 @@
* Use of this software is governed by the Business Source License * Use of this software is governed by the Business Source License
* included in the LICENSE file. * 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 * On the date above, in accordance with the Business Source
* License, use of this software will be governed by version 2 * License, use of this software will be governed by version 2
@ -177,8 +177,16 @@ define([
this.deleteOnClose = false this.deleteOnClose = false
this.closeDialog() this.closeDialog()
} catch (error) { } catch (error) {
// TODO: Error handling
console.error(error) 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)
} }
} }