@@ -8,8 +8,14 @@ part 'inbox_navigation.g.dart';
88/// A request to open the composer, optionally with a recipient chosen.
99class const InboxComposeRequest ({final String ? targetHandle});
1010
11+ /// Which half of the inbox page is shown.
12+ enum InboxView { questions, conversations }
13+
1114class const InboxLocation ({
1215 final bool visible = false ,
16+ final InboxView view = InboxView .questions,
17+ final String ? conversationWorkspace,
18+ final String ? selectedConversationId,
1319 final String ? inboxFilter,
1420 final InboxQuestionStatus ? statusFilter,
1521 final String ? selectedThreadId,
@@ -18,13 +24,23 @@ class const InboxLocation({
1824}) {
1925 InboxLocation copyWith ({
2026 bool ? visible,
27+ InboxView ? view,
28+ String ? Function ()? conversationWorkspace,
29+ String ? Function ()? selectedConversationId,
2130 String ? Function ()? inboxFilter,
2231 InboxQuestionStatus ? Function ()? statusFilter,
2332 String ? Function ()? selectedThreadId,
2433 InboxComposeRequest ? Function ()? compose,
2534 int ? composeSequence,
2635 }) => InboxLocation (
2736 visible: visible ?? this .visible,
37+ view: view ?? this .view,
38+ conversationWorkspace: conversationWorkspace == null
39+ ? this .conversationWorkspace
40+ : conversationWorkspace (),
41+ selectedConversationId: selectedConversationId == null
42+ ? this .selectedConversationId
43+ : selectedConversationId (),
2844 inboxFilter: inboxFilter == null ? this .inboxFilter : inboxFilter (),
2945 statusFilter: statusFilter == null ? this .statusFilter : statusFilter (),
3046 selectedThreadId: selectedThreadId == null
@@ -50,8 +66,17 @@ class InboxNavigation extends _$InboxNavigation {
5066
5167 void close () => state = state.copyWith (visible: false );
5268
53- void selectThread (String ? threadId) =>
54- state = state.copyWith (selectedThreadId: () => threadId);
69+ /// A thread is a question, so selecting one always shows Questions.
70+ void selectThread (String ? threadId) => state = state.copyWith (
71+ view: InboxView .questions,
72+ selectedThreadId: () => threadId,
73+ );
74+
75+ /// Opens the page on Questions, where replies are read.
76+ void openQuestions () {
77+ open ();
78+ state = state.copyWith (view: InboxView .questions);
79+ }
5580
5681 void filterInbox (String ? inbox) => state = state.copyWith (
5782 inboxFilter: () => inbox,
@@ -63,12 +88,23 @@ class InboxNavigation extends _$InboxNavigation {
6388
6489 /// Opens the page and asks it to show the composer once mounted.
6590 void compose ({String ? targetHandle}) {
66- open ();
91+ openQuestions ();
6792 state = state.copyWith (
6893 compose: () => InboxComposeRequest (targetHandle: targetHandle),
6994 composeSequence: state.composeSequence + 1 ,
7095 );
7196 }
7297
7398 void consumeCompose () => state = state.copyWith (compose: () => null );
99+
100+ void showView (InboxView view) => state = state.copyWith (view: view);
101+
102+ void selectConversation (String ? threadId) =>
103+ state = state.copyWith (selectedConversationId: () => threadId);
104+
105+ void filterConversationWorkspace (String ? workspaceId) =>
106+ state = state.copyWith (
107+ conversationWorkspace: () => workspaceId,
108+ selectedConversationId: () => null ,
109+ );
74110}
0 commit comments