mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-05-10 10:28:00 +00:00
FIX: clear uploads after successfully posting new PM
This commit is contained in:
parent
9196546f6f
commit
a3e76c0b2a
@ -3,6 +3,7 @@ import Controller from "@ember/controller";
|
|||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import { getOwner } from "@ember/owner";
|
import { getOwner } from "@ember/owner";
|
||||||
import { service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import UppyUpload from "discourse/lib/uppy/uppy-upload";
|
import UppyUpload from "discourse/lib/uppy/uppy-upload";
|
||||||
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin";
|
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin";
|
||||||
import { clipboardHelpers } from "discourse/lib/utilities";
|
import { clipboardHelpers } from "discourse/lib/utilities";
|
||||||
@ -172,10 +173,15 @@ export default class DiscourseAiBotConversations extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
prepareAndSubmitToBot() {
|
async prepareAndSubmitToBot() {
|
||||||
// Pass uploads to the service before submitting
|
// Pass uploads to the service before submitting
|
||||||
this.aiBotConversationsHiddenSubmit.uploads = this.uploads;
|
this.aiBotConversationsHiddenSubmit.uploads = this.uploads;
|
||||||
this.aiBotConversationsHiddenSubmit.submitToBot();
|
try {
|
||||||
|
await this.aiBotConversationsHiddenSubmit.prepareAndSubmitToBot();
|
||||||
|
this.uploads.clear();
|
||||||
|
} catch (error) {
|
||||||
|
popupAjaxError(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_autoExpandTextarea() {
|
_autoExpandTextarea() {
|
||||||
|
@ -3,7 +3,6 @@ import { next } from "@ember/runloop";
|
|||||||
import Service, { service } from "@ember/service";
|
import Service, { service } from "@ember/service";
|
||||||
import { tracked } from "@ember-compat/tracked-built-ins";
|
import { tracked } from "@ember-compat/tracked-built-ins";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
||||||
import { getUploadMarkdown } from "discourse/lib/uploads";
|
import { getUploadMarkdown } from "discourse/lib/uploads";
|
||||||
import { i18n } from "discourse-i18n";
|
import { i18n } from "discourse-i18n";
|
||||||
|
|
||||||
@ -89,8 +88,6 @@ export default class AiBotConversationsHiddenSubmit extends Service {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.router.transitionTo(response.post_url);
|
this.router.transitionTo(response.post_url);
|
||||||
} catch (e) {
|
|
||||||
popupAjaxError(e);
|
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ export default {
|
|||||||
|
|
||||||
// force Glimmer to re-render that one link
|
// force Glimmer to re-render that one link
|
||||||
this.links = this.links.map((link) =>
|
this.links = this.links.map((link) =>
|
||||||
link.topic.id === topic.id
|
link?.topic?.id === topic.id
|
||||||
? new AiConversationLink(topic)
|
? new AiConversationLink(topic)
|
||||||
: link
|
: link
|
||||||
);
|
);
|
||||||
|
@ -131,6 +131,10 @@ RSpec.describe "AI Bot - Homepage", type: :system do
|
|||||||
expect(topic_page).to have_content("Here are two image attachments")
|
expect(topic_page).to have_content("Here are two image attachments")
|
||||||
expect(page).to have_css(".cooked img", count: 2)
|
expect(page).to have_css(".cooked img", count: 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
find(".ai-new-question-button").click
|
||||||
|
expect(ai_pm_homepage).to have_homepage
|
||||||
|
expect(page).to have_no_css(".ai-bot-upload")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows removing an upload before submission" do
|
it "allows removing an upload before submission" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user