fix: pr view not updating for cached query
This commit is contained in:
@@ -39,20 +39,33 @@ impl PullRequestView {
|
|||||||
|
|
||||||
_ = cx
|
_ = cx
|
||||||
.observe(&query.clone(), move |this, _, cx| {
|
.observe(&query.clone(), move |this, _, cx| {
|
||||||
let maybe_content = {
|
this.load_markdown_content(cx);
|
||||||
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)))
|
|
||||||
})
|
})
|
||||||
.detach();
|
.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();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user