FIX: Include 'notify staff' separator in chat message flag modal (#23301)

When flagging a chat message, and options included both notifying user and notifying staff, the modal was missing the separating text. This was happening because the #staffFlagsAvailable method was based on post flags, and the model for chat flags is slightly different. This fixes that by delegating to the relevant flag target object.
This commit is contained in:
Ted Johansson 2023-08-29 15:26:14 +08:00 committed by GitHub
parent e562bb1f43
commit 7a4119846c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 18 deletions

View File

@ -31,10 +31,8 @@
</div>
</label>
</div>
{{#if @includeSeparator}}
<hr />
{{/if}}
{{#if this.staffFlagsAvailable}}
<hr />
<h3>{{i18n "flagging.notify_staff"}}</h3>
{{/if}}
{{else}}

View File

@ -21,7 +21,6 @@
@username={{@model.flagModel.username}}
@staffFlagsAvailable={{this.staffFlagsAvailable}}
@changePostActionType={{this.changePostActionType}}
@includeSeparator={{this.includeSeparator}}
/>
</FlagSelection>
</form>

View File

@ -7,7 +7,7 @@ import { MAX_MESSAGE_LENGTH } from "discourse/models/post-action-type";
import User from "discourse/models/user";
import { reload } from "discourse/helpers/page-reloader";
const NOTIFY_MODERATORS_ID = 7;
const NOTIFY_MODERATORS_KEY = "notify_moderators";
export default class Flag extends Component {
@service adminTools;
@ -75,13 +75,6 @@ export default class Flag extends Component {
return this.args.model.flagTarget.submitLabel();
}
get includeSeparator() {
return (
this.staffFlagsAvailable ||
this.args.model.flagTarget.includeSeparator?.()
);
}
get title() {
return this.args.model.flagTarget.title();
}
@ -91,7 +84,7 @@ export default class Flag extends Component {
}
get staffFlagsAvailable() {
return this.args.model.flagModel.flagsAvailable?.length > 1;
return this.flagsAvailable.length > 1;
}
get submitEnabled() {
@ -111,7 +104,7 @@ export default class Flag extends Component {
}
get notifyModeratorsFlag() {
return this.flagsAvailable.find((f) => f.id === NOTIFY_MODERATORS_ID);
return this.flagsAvailable.find((f) => f.id === NOTIFY_MODERATORS_KEY);
}
get canTakeAction() {

View File

@ -24,10 +24,6 @@ export default class ChatMessageFlag {
return false;
}
includeSeparator() {
return true;
}
_rewriteFlagDescriptions(flags) {
return flags.map((flag) => {
flag.set(