Let go of the bubble for a message the session died before reading
`Queue::close` reports the messages a dead process never read -- they reached no transcript, so that error is the only place they are ever mentioned -- but it left each one drawn as a bubble waiting to be read, by a session that no longer exists. Nothing would ever clear it: the `UserMessage` that resolves a queued bubble is exactly what is not coming. Seen on the emulator as a grey bubble sitting under its own error message, still saying "tap to take it back", on a session reporting `exited`. It now sends the `MessageDropped` the unqueue route introduced, one per lost message, alongside the error. The error says what happened and the drop is what ends it, which is the same division of labour as the rest of this path.
This commit is contained in:
1 parent
c9d74b63f2
commit
b7277a5a04
1 file changed
+20
-2
@@ -150,10 +150,22 @@ impl Queue {
|
||||
/// Reported rather than dropped. These are messages somebody typed
|
||||
/// that never reached the session and never reached the transcript, so
|
||||
/// this is the only place they can be mentioned at all.
|
||||
///
|
||||
/// Each one is also *resolved*, with the same `MessageDropped` that a
|
||||
/// phone tapping the bubble produces. Without it the bubble sat there
|
||||
/// for good: a message drawn as waiting to be read, by a session that
|
||||
/// no longer exists, with the only thing that ever clears it -- the
|
||||
/// `UserMessage` -- exactly what is not coming. The error says what
|
||||
/// happened and the drop is what ends it, which is the same division
|
||||
/// of labour as everywhere else here.
|
||||
fn close(&mut self, sink: &EventSink, why: &str) {
|
||||
self.closed = true;
|
||||
self.running = false;
|
||||
let lost: Vec<String> = self.awaiting.drain(..).map(|(_, text, _)| text).collect();
|
||||
let lost: Vec<(String, String)> = self
|
||||
.awaiting
|
||||
.drain(..)
|
||||
.map(|(id, text, _)| (id, text))
|
||||
.collect();
|
||||
if lost.is_empty() {
|
||||
return;
|
||||
}
|
||||
@@ -165,9 +177,15 @@ impl Queue {
|
||||
} else {
|
||||
format!("{} queued messages", lost.len())
|
||||
},
|
||||
lost.join(" / ")
|
||||
lost.iter()
|
||||
.map(|(_, text)| text.as_str())
|
||||
.collect::<Vec<_>>()
|
||||
.join(" / ")
|
||||
),
|
||||
});
|
||||
for (id, _) in lost {
|
||||
let _ = sink.send(Event::MessageDropped { id });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user