FIX: uploader not removing app event (#601)

FIX: restricted to mentionabled vs allowed_chat by mistake
This commit is contained in:
Sam 2024-05-06 14:42:55 +10:00 committed by GitHub
parent e4b326c711
commit 37a2db5223
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -3,7 +3,6 @@ import Component, { Input } from "@ember/component";
import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import willDestroy from "@ember/render-modifiers/modifiers/will-destroy";
import { inject as service } from "@ember/service";
import DButton from "discourse/components/d-button";
import { ajax } from "discourse/lib/ajax";
@ -52,8 +51,13 @@ export default class PersonaRagUploader extends Component.extend(
);
}
removeListener() {
this.appEvents.off(`upload-mixin:${this.id}:all-uploads-complete`);
willDestroy() {
super.willDestroy(...arguments);
this.appEvents.off(
`upload-mixin:${this.id}:all-uploads-complete`,
this,
"_updatePersonaWithUploads"
);
}
_updatePersonaWithUploads() {
@ -108,7 +112,7 @@ export default class PersonaRagUploader extends Component.extend(
}
<template>
<div class="persona-rag-uploader" {{willDestroy this.removeListener}}>
<div class="persona-rag-uploader">
<h3>{{I18n.t "discourse_ai.ai_persona.uploads.title"}}</h3>
<p>{{I18n.t "discourse_ai.ai_persona.uploads.description"}}</p>

View File

@ -101,8 +101,8 @@ module DiscourseAi
def inject_into(plugin)
plugin.register_modifier(:chat_allowed_bot_user_ids) do |user_ids, guardian|
if guardian.user
mentionables = AiPersona.mentionables(user: guardian.user)
allowed_bot_ids = mentionables.map { |mentionable| mentionable[:user_id] }
allowed_chat = AiPersona.allowed_chat(user: guardian.user)
allowed_bot_ids = allowed_chat.map { |info| info[:user_id] }
user_ids.concat(allowed_bot_ids)
end
user_ids