Fix slow mode:
focus was lost when textarea got disabled, so it could trigger some Peertube events if the user type some text.
This commit is contained in:
parent
543f18c727
commit
1ceb37da2c
@ -19,6 +19,7 @@ TODO: https://github.com/JohnXLivingston/peertube-plugin-livechat/issues/48
|
||||
|
||||
* Some code refactoring.
|
||||
* New translations: Galician.
|
||||
* Fix slow mode: focus was lost when textarea got disabled, so it could trigger some Peertube events if the user type some text.
|
||||
|
||||
## 8.4.0
|
||||
|
||||
|
@ -123,3 +123,10 @@ body.converse-embedded {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.conversejs {
|
||||
// Fix: for the slow mode, we use readonly instead of disabled, we must apply same CSS as ConverseJS.
|
||||
textarea:read-only {
|
||||
background-color: var(--chat-textarea-disabled-bg-color) !important;
|
||||
}
|
||||
}
|
||||
|
@ -31,15 +31,12 @@ export const slowModePlugin = {
|
||||
// FIXME: field could be enabled by something else (another event in ConverseJS).
|
||||
// This is not very important: the server will reject messages anyway.
|
||||
|
||||
textarea.classList.add('disabled')
|
||||
textarea.setAttribute('disabled', 'disabled')
|
||||
textarea.setAttribute('readonly', 'readonly')
|
||||
// Note: we are adding a 100ms delay.
|
||||
// To minimize the risk that user can send a message before the server will accept it
|
||||
// (if the first message lagged for example)
|
||||
setTimeout(() => {
|
||||
textarea.classList.remove('disabled')
|
||||
textarea.removeAttribute('disabled');
|
||||
(textarea as HTMLTextAreaElement).focus()
|
||||
textarea.removeAttribute('readonly')
|
||||
}, slowModeDuration * 1000 + 100)
|
||||
})
|
||||
}, 100)
|
||||
|
Loading…
x
Reference in New Issue
Block a user