util: Option<UtilityActivity>,
}
+impl Activity {
+ pub fn throw_into_mentions(&self) -> bool {
+ // ReadMentions itself doesn't count. This will have to return
+ // false for post-editing activities.
+ match self {
+ _ => true,
+ }
+ }
+}
+
impl ActivityStack {
pub fn new() -> Self {
ActivityStack {
},
Ok(SubthreadEvent::StreamEv(update)) => {
match self.client.process_stream_update(update) {
- Ok(feeds_updated) =>
- state.handle_feed_updates(feeds_updated,
- &mut self.client),
+ Ok(feeds_updated) => {
+ match state.handle_feed_updates(feeds_updated,
+ &mut self.client) {
+ PhysicalAction::Beep => {
+ Self::beep()?
+ },
+
+ PhysicalAction::Exit => {
+ break 'outer Ok(());
+ },
+
+ PhysicalAction::Error(err) => {
+ break 'outer Err(err);
+ },
+
+ PhysicalAction::Nothing => (),
+ }
+ },
// FIXME: errors here should go in the Error Log
_ => (),
}
fn handle_feed_updates(&mut self, feeds_updated: HashSet<FeedId>,
- client: &mut Client) {
- // FIXME: if the mentions feed is updated, we may need to
- // actually change the activity stack to throw the user into
- // Read Messages.
-
+ client: &mut Client) -> PhysicalAction {
self.activity_state.handle_feed_updates(&feeds_updated, client);
+
+ if feeds_updated.contains(&FeedId::Mentions) {
+ if self.activity_stack.top().throw_into_mentions() {
+ self.activity_stack.goto(UtilityActivity::ReadMentions.into());
+ self.changed_activity(client);
+ }
+
+ // FIXME: we'd quite like a double-beep if you're in the composer
+ PhysicalAction::Beep
+ } else {
+ PhysicalAction::Nothing
+ }
}
fn changed_activity(&mut self, client: &mut Client) {