fix(chat): Retry and Send now under a failed message work again (#160)
@@ -166,12 +166,15 @@ impl RenderEnv {
166
166
let (view, key, handle) = (view.clone(), message.key.clone(), window.window_handle());
167
167
boxed(move |cx| {
168
168
let (view, key) = (view.clone(), key.clone());
169
handle
170
.update(cx, move |_, window, cx| {
171
view.update(cx, |this, cx| this.retry(&key, window, cx))
172
.ok();
173
})
174
.ok();
169
// The click runs inside this window's update, which `handle.update` cannot reenter.
170
cx.defer(move |cx| {
171
handle
172
.update(cx, move |_, window, cx| {
173
view.update(cx, |this, cx| this.retry(&key, window, cx))
174
.ok();
175
})
176
.ok();
177
});
175
178
})
176
179
});
177
180
let scheduled = view.upgrade().and_then(|entity| {
@@ -166,12 +166,15 @@ impl RenderEnv {166
let (view, key, handle) = (view.clone(), message.key.clone(), window.window_handle());166
let (view, key, handle) = (view.clone(), message.key.clone(), window.window_handle());167
boxed(move |cx| {167
boxed(move |cx| {168
let (view, key) = (view.clone(), key.clone());168
let (view, key) = (view.clone(), key.clone());169
handle169
// The click runs inside this window's update, which `handle.update` cannot reenter.170
.update(cx, move |_, window, cx| {170
cx.defer(move |cx| {171
view.update(cx, |this, cx| this.retry(&key, window, cx))171
handle172
.ok();172
.update(cx, move |_, window, cx| {173
})173
view.update(cx, |this, cx| this.retry(&key, window, cx))174
.ok();174
.ok();175
})176
.ok();177
});175
})178
})176
});179
});177
let scheduled = view.upgrade().and_then(|entity| {180
let scheduled = view.upgrade().and_then(|entity| {@@ -435,29 +435,34 @@ impl ConversationView {
435
435
cx: &App,
436
436
) -> Option<ScheduledRowActions> {
437
437
let draft_id = draft_id_of(&row.key)?.to_owned();
438
// These links run inside this window's update, which `handle.update` cannot reenter: defer it.
438
439
let handle = window.window_handle();
439
440
let link = |run: fn(&mut Self, &str, &mut Window, &mut Context<Self>)| -> RowAction {
440
441
let (view, draft_id) = (view.clone(), draft_id.clone());
441
442
Some(Box::new(move |cx: &mut App| {
442
443
let (view, draft_id) = (view.clone(), draft_id.clone());
443
handle
444
.update(cx, move |_, window, cx| {
445
view.update(cx, |this, cx| run(this, &draft_id, window, cx))
446
.ok();
447
})
448
.ok();
444
cx.defer(move |cx| {
445
handle
446
.update(cx, move |_, window, cx| {
447
view.update(cx, |this, cx| run(this, &draft_id, window, cx))
448
.ok();
449
})
450
.ok();
451
});
449
452
}))
450
453
};
451
454
let retry: RowAction = {
452
455
let view = view.clone();
453
456
Some(Box::new(move |cx: &mut App| {
454
457
let view = view.clone();
455
handle
456
.update(cx, move |_, window, cx| {
457
view.update(cx, |this, cx| this.retry_scheduled(window, cx))
458
.ok();
459
})
460
.ok();
458
cx.defer(move |cx| {
459
handle
460
.update(cx, move |_, window, cx| {
461
view.update(cx, |this, cx| this.retry_scheduled(window, cx))
462
.ok();
463
})
464
.ok();
465
});
461
466
}))
462
467
};
463
468
let action = |run: fn(&mut Self, &str, &mut Window, &mut Context<Self>)| -> Action {
@@ -435,29 +435,34 @@ impl ConversationView {435
cx: &App,435
cx: &App,436
) -> Option<ScheduledRowActions> {436
) -> Option<ScheduledRowActions> {437
let draft_id = draft_id_of(&row.key)?.to_owned();437
let draft_id = draft_id_of(&row.key)?.to_owned();438
// These links run inside this window's update, which `handle.update` cannot reenter: defer it.438
let handle = window.window_handle();439
let handle = window.window_handle();439
let link = |run: fn(&mut Self, &str, &mut Window, &mut Context<Self>)| -> RowAction {440
let link = |run: fn(&mut Self, &str, &mut Window, &mut Context<Self>)| -> RowAction {440
let (view, draft_id) = (view.clone(), draft_id.clone());441
let (view, draft_id) = (view.clone(), draft_id.clone());441
Some(Box::new(move |cx: &mut App| {442
Some(Box::new(move |cx: &mut App| {442
let (view, draft_id) = (view.clone(), draft_id.clone());443
let (view, draft_id) = (view.clone(), draft_id.clone());443
handle444
cx.defer(move |cx| {444
.update(cx, move |_, window, cx| {445
handle445
view.update(cx, |this, cx| run(this, &draft_id, window, cx))446
.update(cx, move |_, window, cx| {446
.ok();447
view.update(cx, |this, cx| run(this, &draft_id, window, cx))447
})448
.ok();448
.ok();449
})450
.ok();451
});449
}))452
}))450
};453
};451
let retry: RowAction = {454
let retry: RowAction = {452
let view = view.clone();455
let view = view.clone();453
Some(Box::new(move |cx: &mut App| {456
Some(Box::new(move |cx: &mut App| {454
let view = view.clone();457
let view = view.clone();455
handle458
cx.defer(move |cx| {456
.update(cx, move |_, window, cx| {459
handle457
view.update(cx, |this, cx| this.retry_scheduled(window, cx))460
.update(cx, move |_, window, cx| {458
.ok();461
view.update(cx, |this, cx| this.retry_scheduled(window, cx))459
})462
.ok();460
.ok();463
})464
.ok();465
});461
}))466
}))462
};467
};463
let action = |run: fn(&mut Self, &str, &mut Window, &mut Context<Self>)| -> Action {468
let action = |run: fn(&mut Self, &str, &mut Window, &mut Context<Self>)| -> Action {