fix: pr view not updating for cached query
This commit is contained in:
@@ -39,6 +39,22 @@ impl PullRequestView {
|
|||||||
|
|
||||||
_ = cx
|
_ = cx
|
||||||
.observe(&query.clone(), move |this, _, cx| {
|
.observe(&query.clone(), move |this, _, 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 maybe_content = {
|
||||||
let data = read_query(&query, cx);
|
let data = read_query(&query, cx);
|
||||||
if let QueryStatus::Loaded(pr) = data {
|
if let QueryStatus::Loaded(pr) = data {
|
||||||
@@ -48,10 +64,7 @@ impl PullRequestView {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.markdown_viewer =
|
self.markdown_viewer = maybe_content.map(|content| cx.new(|cx| markdown::new(content, cx)));
|
||||||
maybe_content.map(|content| cx.new(|cx| markdown::new(content, cx)))
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user