Use read-only access methods for read-only entity operations (#31479)
Another follow-up to #31254 Release Notes: - N/A
This commit is contained in:
parent
4a577fff4a
commit
c208532693
79 changed files with 319 additions and 306 deletions
|
@ -387,7 +387,7 @@ impl ChannelChat {
|
|||
let loaded_messages = messages_from_proto(proto_messages, &user_store, cx).await?;
|
||||
|
||||
let first_loaded_message_id = loaded_messages.first().map(|m| m.id);
|
||||
let loaded_message_ids = this.update(cx, |this, _| {
|
||||
let loaded_message_ids = this.read_with(cx, |this, _| {
|
||||
let mut loaded_message_ids: HashSet<u64> = HashSet::default();
|
||||
for message in loaded_messages.iter() {
|
||||
if let Some(saved_message_id) = message.id.into() {
|
||||
|
@ -457,7 +457,7 @@ impl ChannelChat {
|
|||
)
|
||||
.await?;
|
||||
|
||||
let pending_messages = this.update(cx, |this, _| {
|
||||
let pending_messages = this.read_with(cx, |this, _| {
|
||||
this.pending_messages().cloned().collect::<Vec<_>>()
|
||||
})?;
|
||||
|
||||
|
@ -531,7 +531,7 @@ impl ChannelChat {
|
|||
message: TypedEnvelope<proto::ChannelMessageSent>,
|
||||
mut cx: AsyncApp,
|
||||
) -> Result<()> {
|
||||
let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;
|
||||
let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;
|
||||
let message = message.payload.message.context("empty message")?;
|
||||
let message_id = message.id;
|
||||
|
||||
|
@ -563,7 +563,7 @@ impl ChannelChat {
|
|||
message: TypedEnvelope<proto::ChannelMessageUpdate>,
|
||||
mut cx: AsyncApp,
|
||||
) -> Result<()> {
|
||||
let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;
|
||||
let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;
|
||||
let message = message.payload.message.context("empty message")?;
|
||||
|
||||
let message = ChannelMessage::from_proto(message, &user_store, &mut cx).await?;
|
||||
|
|
|
@ -333,7 +333,7 @@ impl ChannelStore {
|
|||
if let Some(request) = request {
|
||||
let response = request.await?;
|
||||
let this = this.upgrade().context("channel store dropped")?;
|
||||
let user_store = this.update(cx, |this, _| this.user_store.clone())?;
|
||||
let user_store = this.read_with(cx, |this, _| this.user_store.clone())?;
|
||||
ChannelMessage::from_proto_vec(response.messages, &user_store, cx).await
|
||||
} else {
|
||||
Ok(Vec::new())
|
||||
|
@ -478,7 +478,7 @@ impl ChannelStore {
|
|||
hash_map::Entry::Vacant(e) => {
|
||||
let task = cx
|
||||
.spawn(async move |this, cx| {
|
||||
let channel = this.update(cx, |this, _| {
|
||||
let channel = this.read_with(cx, |this, _| {
|
||||
this.channel_for_id(channel_id).cloned().ok_or_else(|| {
|
||||
Arc::new(anyhow!("no channel for id: {channel_id}"))
|
||||
})
|
||||
|
@ -848,7 +848,7 @@ impl ChannelStore {
|
|||
message: TypedEnvelope<proto::UpdateChannels>,
|
||||
mut cx: AsyncApp,
|
||||
) -> Result<()> {
|
||||
this.update(&mut cx, |this, _| {
|
||||
this.read_with(&mut cx, |this, _| {
|
||||
this.update_channels_tx
|
||||
.unbounded_send(message.payload)
|
||||
.unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue