@@ -54,7 +54,11 @@ class ChatMasterDetailPage extends StatelessWidget with WatchItMixin {
5454 ),
5555 );
5656 } else {
57- _commandDoneCleanupSnackbars (context);
57+ Future .delayed (const Duration (seconds: 1 ), () {
58+ if (context.mounted) {
59+ ScaffoldMessenger .of (context).clearSnackBars ();
60+ }
61+ });
5862 }
5963 },
6064 );
@@ -63,50 +67,56 @@ class ChatMasterDetailPage extends StatelessWidget with WatchItMixin {
6367 select: (EditRoomManager m) => m.globalLeaveRoomCommand.results,
6468 handler: (context, newValue, cancel) {
6569 if (newValue.isRunning) {
66- _showInifniteSpinnerSnackbar (
70+ _showIndeterminateSpinnerSnackbar (
6771 context,
6872 '${context .l10n .leave } ${newValue .data ?.getLocalizedDisplayname () ?? '' }' ,
6973 );
70- } else if (newValue.hasData && newValue.data != null ) {
74+ } else if (newValue.hasError ) {
7175 ScaffoldMessenger .of (context)
7276 ..clearSnackBars ()
7377 ..showSnackBar (
7478 SnackBar (
75- duration: const Duration (seconds: 5 ),
7679 content: Text (
77- 'Left: ${newValue .data ?.getLocalizedDisplayname () ?? '' }' ,
78- ),
79- action: SnackBarAction (
80- label: context.l10n.delete,
81- onPressed: () {
82- di <EditRoomManager >().globalForgetRoomCommand.run (
83- newValue.data! ,
84- );
85- },
80+ '${context .l10n .oopsSomethingWentWrong } ${newValue .data ?.getLocalizedDisplayname () ?? '' }: ${newValue .error }' ,
8681 ),
8782 ),
8883 );
89- } else if (newValue.hasError ) {
90- ScaffoldMessenger .of (context)
91- .. clearSnackBars ()
92- . .showSnackBar (
84+ } else if (newValue.hasData ) {
85+ ScaffoldMessenger .of (context). clearSnackBars ();
86+ if (newValue.data != null ) {
87+ ScaffoldMessenger . of (context) .showSnackBar (
9388 SnackBar (
9489 content: Text (
95- '${context .l10n .oopsSomethingWentWrong } ${newValue .data ?.getLocalizedDisplayname () ?? '' }: ${newValue .error }' ,
90+ 'Left: ${newValue .data ?.getLocalizedDisplayname () ?? '' }' ,
91+ ),
92+ action: SnackBarAction (
93+ label: context.l10n.delete,
94+ onPressed: () => di <EditRoomManager >().globalForgetRoomCommand
95+ .run (newValue.data! ),
9696 ),
9797 ),
9898 );
99+ }
99100 } else {
100- _commandDoneCleanupSnackbars (context);
101+ Future .delayed (const Duration (seconds: 4 ), () {
102+ if (context.mounted) {
103+ ScaffoldMessenger .of (context).clearSnackBars ();
104+ }
105+ });
101106 }
102107 },
103108 );
104109
110+ registerHandler (
111+ select: (EditRoomManager m) => m.globalLeaveRoomCommand,
112+ handler: (context, newValue, cancel) {},
113+ );
114+
105115 registerHandler (
106116 select: (EditRoomManager m) => m.globalForgetRoomCommand.results,
107117 handler: (context, newValue, cancel) {
108118 if (newValue.isRunning) {
109- _showInifniteSpinnerSnackbar (
119+ _showIndeterminateSpinnerSnackbar (
110120 context,
111121 '${context .l10n .delete } ${newValue .data ?.getLocalizedDisplayname () ?? '' }' ,
112122 );
@@ -130,8 +140,6 @@ class ChatMasterDetailPage extends StatelessWidget with WatchItMixin {
130140 ),
131141 ),
132142 );
133- } else {
134- _commandDoneCleanupSnackbars (context);
135143 }
136144 },
137145 );
@@ -219,30 +227,24 @@ class ChatMasterDetailPage extends StatelessWidget with WatchItMixin {
219227 );
220228 }
221229
222- void _showInifniteSpinnerSnackbar (BuildContext context, String text) {
223- ScaffoldMessenger .of (context).showSnackBar (
224- SnackBar (
225- duration: const Duration (seconds: 5 ),
226- content: Row (
227- children: [
228- const SizedBox (
229- width: 20 ,
230- height: 20 ,
231- child: CircularProgressIndicator (strokeWidth: 2 ),
232- ),
233- const SizedBox (width: 16 ),
234- Text (text),
235- ],
230+ void _showIndeterminateSpinnerSnackbar (BuildContext context, String text) {
231+ ScaffoldMessenger .of (context)
232+ ..clearSnackBars ()
233+ ..showSnackBar (
234+ SnackBar (
235+ duration: const Duration (seconds: 100 ),
236+ content: Row (
237+ children: [
238+ const SizedBox (
239+ width: 20 ,
240+ height: 20 ,
241+ child: CircularProgressIndicator (strokeWidth: 2 ),
242+ ),
243+ const SizedBox (width: 16 ),
244+ Text (text),
245+ ],
246+ ),
236247 ),
237- ),
238- );
239- }
240-
241- void _commandDoneCleanupSnackbars (BuildContext context) {
242- Future .delayed (const Duration (seconds: 2 ), () {
243- if (context.mounted) {
244- ScaffoldMessenger .of (context).clearSnackBars ();
245- }
246- });
248+ );
247249 }
248250}
0 commit comments