Use read()
over read_with()
to improve readability in simple cases (#31263)
Release Notes: - N/A
This commit is contained in:
parent
e88cad29e5
commit
6206150e27
5 changed files with 11 additions and 18 deletions
|
@ -153,13 +153,10 @@ impl Render for ProfileSelector {
|
|||
.map(|profile| profile.name.clone())
|
||||
.unwrap_or_else(|| "Unknown".into());
|
||||
|
||||
let configured_model = self
|
||||
.thread
|
||||
.read_with(cx, |thread, _cx| thread.configured_model())
|
||||
.or_else(|| {
|
||||
let model_registry = LanguageModelRegistry::read_global(cx);
|
||||
model_registry.default_model()
|
||||
});
|
||||
let configured_model = self.thread.read(cx).configured_model().or_else(|| {
|
||||
let model_registry = LanguageModelRegistry::read_global(cx);
|
||||
model_registry.default_model()
|
||||
});
|
||||
let supports_tools =
|
||||
configured_model.map_or(false, |default| default.model.supports_tools());
|
||||
|
||||
|
|
|
@ -109,9 +109,7 @@ impl ProjectSharedNotification {
|
|||
}
|
||||
|
||||
fn dismiss(&mut self, cx: &mut Context<Self>) {
|
||||
if let Some(active_room) =
|
||||
ActiveCall::global(cx).read_with(cx, |call, _| call.room().cloned())
|
||||
{
|
||||
if let Some(active_room) = ActiveCall::global(cx).read(cx).room().cloned() {
|
||||
active_room.update(cx, |_, cx| {
|
||||
cx.emit(room::Event::RemoteProjectInvitationDiscarded {
|
||||
project_id: self.project_id,
|
||||
|
|
|
@ -349,9 +349,7 @@ impl DebugPanel {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
while let Some(parent_session) =
|
||||
curr_session.read_with(cx, |session, _| session.parent_session().cloned())
|
||||
{
|
||||
while let Some(parent_session) = curr_session.read(cx).parent_session().cloned() {
|
||||
curr_session = parent_session;
|
||||
}
|
||||
|
||||
|
|
|
@ -1121,10 +1121,10 @@ impl MultiBuffer {
|
|||
|
||||
pub fn last_transaction_id(&self, cx: &App) -> Option<TransactionId> {
|
||||
if let Some(buffer) = self.as_singleton() {
|
||||
return buffer.read_with(cx, |b, _| {
|
||||
b.peek_undo_stack()
|
||||
.map(|history_entry| history_entry.transaction_id())
|
||||
});
|
||||
return buffer
|
||||
.read(cx)
|
||||
.peek_undo_stack()
|
||||
.map(|history_entry| history_entry.transaction_id());
|
||||
} else {
|
||||
let last_transaction = self.history.undo_stack.last()?;
|
||||
return Some(last_transaction.id);
|
||||
|
|
|
@ -536,7 +536,7 @@ impl HeadlessProject {
|
|||
});
|
||||
}
|
||||
|
||||
let buffer_id = buffer.read_with(cx, |b, _| b.remote_id());
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
|
||||
buffer_store.update(cx, |buffer_store, cx| {
|
||||
buffer_store
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue