fix: pr view not updating for cached query

This commit is contained in:
2026-05-11 02:34:09 +08:00
parent 6c0283d7a3
commit bfcfac61e8

View File

@@ -39,20 +39,33 @@ impl PullRequestView {
_ = cx
.observe(&query.clone(), move |this, _, cx| {
let maybe_content = {
let data = read_query(&query, cx);
if let QueryStatus::Loaded(pr) = data {
Some(gpui::SharedString::new(pr.body.as_str()))
} else {
None
}
};
this.markdown_viewer =
maybe_content.map(|content| cx.new(|cx| markdown::new(content, cx)))
this.load_markdown_content(cx);
})
.detach();
// cached query will not trigger observe callback
// this is required so that content is loaded immediately for cached query
self.load_markdown_content(cx);
cx.notify();
}
fn load_markdown_content(&mut self, cx: &mut gpui::Context<Self>) {
let Some(query) = &self.pull_request_query else {
return;
};
let maybe_content = {
let data = read_query(&query, cx);
if let QueryStatus::Loaded(pr) = data {
Some(gpui::SharedString::new(pr.body.as_str()))
} else {
None
}
};
self.markdown_viewer = maybe_content.map(|content| cx.new(|cx| markdown::new(content, cx)));
cx.notify();
}