mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: prevents saving draft in incorrect channel (#21741)
This commit regroups 3 changes - serializes channel ID and json draft when calling the debouncer instead of inside the debounced function, it seems very unlikely to happen, but in a case where the debouncing wouldn't be canceled and the new message not set yet, we could save the draft on an invalid channel - cancel persist draft handler when changing channel - ensures we exit early when channel is not set
This commit is contained in:
parent
082921c4c8
commit
398eaf0429
@ -146,8 +146,11 @@ export default class ChatComposer extends Component {
|
||||
|
||||
@action
|
||||
didUpdateChannel() {
|
||||
this.cancelPersistDraft();
|
||||
|
||||
if (!this.args.channel) {
|
||||
this.composer.message = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.composer.message =
|
||||
|
@ -29,16 +29,15 @@ export default class ChatComposerChannel extends ChatComposer {
|
||||
this._persistHandler = discourseDebounce(
|
||||
this,
|
||||
this._debouncedPersistDraft,
|
||||
this.args.channel.id,
|
||||
this.currentMessage.toJSONDraft(),
|
||||
2000
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
_debouncedPersistDraft() {
|
||||
this.chatApi.saveDraft(
|
||||
this.args.channel.id,
|
||||
this.currentMessage.toJSONDraft()
|
||||
);
|
||||
_debouncedPersistDraft(channelId, jsonDraft) {
|
||||
this.chatApi.saveDraft(channelId, jsonDraft);
|
||||
}
|
||||
|
||||
get placeholder() {
|
||||
|
Loading…
Reference in New Issue
Block a user