@@ -103,9 +103,11 @@ extension MessageStateX on MessageState {
103
103
104
104
/// Returns true if the message is in failed updating state.
105
105
bool get isUpdatingFailed {
106
- final messageState = this ;
107
- if (messageState is ! MessageFailed ) return false ;
108
- return messageState.state is UpdatingFailed ;
106
+ return switch (this ) {
107
+ MessageFailed (state: UpdatingFailed ()) => true ,
108
+ MessageFailed (state: PartialUpdatingFailed ()) => true ,
109
+ _ => false ,
110
+ };
109
111
}
110
112
111
113
/// Returns true if the message is in failed deleting state.
@@ -182,6 +184,46 @@ sealed class MessageState with _$MessageState {
182
184
);
183
185
}
184
186
187
+ /// Sending failed state when the message fails to be sent.
188
+ factory MessageState .sendingFailed ({
189
+ required bool skipPush,
190
+ required bool skipEnrichUrl,
191
+ }) {
192
+ return MessageState .failed (
193
+ state: FailedState .sendingFailed (
194
+ skipPush: skipPush,
195
+ skipEnrichUrl: skipEnrichUrl,
196
+ ),
197
+ );
198
+ }
199
+
200
+ /// Updating failed state when the message fails to be updated.
201
+ factory MessageState .updatingFailed ({
202
+ required bool skipPush,
203
+ required bool skipEnrichUrl,
204
+ }) {
205
+ return MessageState .failed (
206
+ state: FailedState .updatingFailed (
207
+ skipPush: skipPush,
208
+ skipEnrichUrl: skipEnrichUrl,
209
+ ),
210
+ );
211
+ }
212
+
213
+ factory MessageState .partialUpdatingFailed ({
214
+ Map <String , Object ?>? set ,
215
+ List <String >? unset,
216
+ required bool skipEnrichUrl,
217
+ }) {
218
+ return MessageState .failed (
219
+ state: FailedState .partialUpdatingFailed (
220
+ set : set ,
221
+ unset: unset,
222
+ skipEnrichUrl: skipEnrichUrl,
223
+ ),
224
+ );
225
+ }
226
+
185
227
/// Sending state when the message is being sent.
186
228
static const sending = MessageState .outgoing (
187
229
state: OutgoingState .sending (),
@@ -222,16 +264,6 @@ sealed class MessageState with _$MessageState {
222
264
state: CompletedState .deleted (hard: true ),
223
265
);
224
266
225
- /// Sending failed state when the message fails to be sent.
226
- static const sendingFailed = MessageState .failed (
227
- state: FailedState .sendingFailed (),
228
- );
229
-
230
- /// Updating failed state when the message fails to be updated.
231
- static const updatingFailed = MessageState .failed (
232
- state: FailedState .updatingFailed (),
233
- );
234
-
235
267
/// Deleting failed state when the message fails to be soft deleted.
236
268
static const softDeletingFailed = MessageState .failed (
237
269
state: FailedState .deletingFailed (),
@@ -285,10 +317,22 @@ sealed class CompletedState with _$CompletedState {
285
317
@freezed
286
318
sealed class FailedState with _$FailedState {
287
319
/// Sending failed state when the message fails to be sent.
288
- const factory FailedState .sendingFailed () = SendingFailed ;
320
+ const factory FailedState .sendingFailed ({
321
+ @Default (false ) bool skipPush,
322
+ @Default (false ) bool skipEnrichUrl,
323
+ }) = SendingFailed ;
289
324
290
325
/// Updating failed state when the message fails to be updated.
291
- const factory FailedState .updatingFailed () = UpdatingFailed ;
326
+ const factory FailedState .updatingFailed ({
327
+ @Default (false ) bool skipPush,
328
+ @Default (false ) bool skipEnrichUrl,
329
+ }) = UpdatingFailed ;
330
+
331
+ const factory FailedState .partialUpdatingFailed ({
332
+ Map <String , Object ?>? set ,
333
+ List <String >? unset,
334
+ @Default (false ) bool skipEnrichUrl,
335
+ }) = PartialUpdatingFailed ;
292
336
293
337
/// Deleting failed state when the message fails to be deleted.
294
338
const factory FailedState .deletingFailed ({
@@ -616,45 +660,66 @@ extension FailedStatePatternMatching on FailedState {
616
660
/// @nodoc
617
661
@optionalTypeArgs
618
662
TResult when < TResult extends Object ? > ({
619
- required TResult Function () sendingFailed,
620
- required TResult Function () updatingFailed,
663
+ required TResult Function (bool skipPush, bool skipEnrichUrl) sendingFailed,
664
+ required TResult Function (bool skipPush, bool skipEnrichUrl) updatingFailed,
665
+ required TResult Function (
666
+ Map <String , Object ?>? set , List <String >? unset, bool skipEnrichUrl)
667
+ partialUpdatingFailed,
621
668
required TResult Function (bool hard) deletingFailed,
622
669
}) {
623
670
final failedState = this ;
624
671
return switch (failedState) {
625
- SendingFailed () => sendingFailed (),
626
- UpdatingFailed () => updatingFailed (),
672
+ SendingFailed () =>
673
+ sendingFailed (failedState.skipPush, failedState.skipEnrichUrl),
674
+ UpdatingFailed () =>
675
+ updatingFailed (failedState.skipPush, failedState.skipEnrichUrl),
676
+ PartialUpdatingFailed () => partialUpdatingFailed (
677
+ failedState.set , failedState.unset, failedState.skipEnrichUrl),
627
678
DeletingFailed () => deletingFailed (failedState.hard),
628
679
};
629
680
}
630
681
631
682
/// @nodoc
632
683
@optionalTypeArgs
633
684
TResult ? whenOrNull <TResult extends Object ?>({
634
- TResult ? Function ()? sendingFailed,
635
- TResult ? Function ()? updatingFailed,
685
+ TResult ? Function (bool skipPush, bool skipEnrichUrl)? sendingFailed,
686
+ TResult ? Function (bool skipPush, bool skipEnrichUrl)? updatingFailed,
687
+ required TResult Function (
688
+ Map <String , Object ?>? set , List <String >? unset, bool skipEnrichUrl)
689
+ partialUpdatingFailed,
636
690
TResult ? Function (bool hard)? deletingFailed,
637
691
}) {
638
692
final failedState = this ;
639
693
return switch (failedState) {
640
- SendingFailed () => sendingFailed? .call (),
641
- UpdatingFailed () => updatingFailed? .call (),
694
+ SendingFailed () =>
695
+ sendingFailed? .call (failedState.skipPush, failedState.skipEnrichUrl),
696
+ UpdatingFailed () =>
697
+ updatingFailed? .call (failedState.skipPush, failedState.skipEnrichUrl),
698
+ PartialUpdatingFailed () => partialUpdatingFailed (
699
+ failedState.set , failedState.unset, failedState.skipEnrichUrl),
642
700
DeletingFailed () => deletingFailed? .call (failedState.hard),
643
701
};
644
702
}
645
703
646
704
/// @nodoc
647
705
@optionalTypeArgs
648
706
TResult maybeWhen <TResult extends Object ?>({
649
- TResult Function ()? sendingFailed,
650
- TResult Function ()? updatingFailed,
707
+ TResult Function (bool skipPush, bool skipEnrichUrl)? sendingFailed,
708
+ TResult Function (bool skipPush, bool skipEnrichUrl)? updatingFailed,
709
+ required TResult Function (
710
+ Map <String , Object ?>? set , List <String >? unset, bool skipEnrichUrl)
711
+ partialUpdatingFailed,
651
712
TResult Function (bool hard)? deletingFailed,
652
713
required TResult orElse (),
653
714
}) {
654
715
final failedState = this ;
655
716
final result = switch (failedState) {
656
- SendingFailed () => sendingFailed? .call (),
657
- UpdatingFailed () => updatingFailed? .call (),
717
+ SendingFailed () =>
718
+ sendingFailed? .call (failedState.skipPush, failedState.skipEnrichUrl),
719
+ UpdatingFailed () =>
720
+ updatingFailed? .call (failedState.skipPush, failedState.skipEnrichUrl),
721
+ PartialUpdatingFailed () => partialUpdatingFailed (
722
+ failedState.set , failedState.unset, failedState.skipEnrichUrl),
658
723
DeletingFailed () => deletingFailed? .call (failedState.hard),
659
724
};
660
725
@@ -666,12 +731,15 @@ extension FailedStatePatternMatching on FailedState {
666
731
TResult map <TResult extends Object ?>({
667
732
required TResult Function (SendingFailed value) sendingFailed,
668
733
required TResult Function (UpdatingFailed value) updatingFailed,
734
+ required TResult Function (PartialUpdatingFailed value)
735
+ partialUpdatingFailed,
669
736
required TResult Function (DeletingFailed value) deletingFailed,
670
737
}) {
671
738
final failedState = this ;
672
739
return switch (failedState) {
673
740
SendingFailed () => sendingFailed (failedState),
674
741
UpdatingFailed () => updatingFailed (failedState),
742
+ PartialUpdatingFailed () => partialUpdatingFailed (failedState),
675
743
DeletingFailed () => deletingFailed (failedState),
676
744
};
677
745
}
@@ -681,12 +749,14 @@ extension FailedStatePatternMatching on FailedState {
681
749
TResult ? mapOrNull <TResult extends Object ?>({
682
750
TResult ? Function (SendingFailed value)? sendingFailed,
683
751
TResult ? Function (UpdatingFailed value)? updatingFailed,
752
+ TResult ? Function (PartialUpdatingFailed value)? partialUpdatingFailed,
684
753
TResult ? Function (DeletingFailed value)? deletingFailed,
685
754
}) {
686
755
final failedState = this ;
687
756
return switch (failedState) {
688
757
SendingFailed () => sendingFailed? .call (failedState),
689
758
UpdatingFailed () => updatingFailed? .call (failedState),
759
+ PartialUpdatingFailed () => partialUpdatingFailed? .call (failedState),
690
760
DeletingFailed () => deletingFailed? .call (failedState),
691
761
};
692
762
}
@@ -696,13 +766,15 @@ extension FailedStatePatternMatching on FailedState {
696
766
TResult maybeMap <TResult extends Object ?>({
697
767
TResult Function (SendingFailed value)? sendingFailed,
698
768
TResult Function (UpdatingFailed value)? updatingFailed,
769
+ TResult Function (PartialUpdatingFailed value)? partialUpdatingFailed,
699
770
TResult Function (DeletingFailed value)? deletingFailed,
700
771
required TResult orElse (),
701
772
}) {
702
773
final failedState = this ;
703
774
final result = switch (failedState) {
704
775
SendingFailed () => sendingFailed? .call (failedState),
705
776
UpdatingFailed () => updatingFailed? .call (failedState),
777
+ PartialUpdatingFailed () => partialUpdatingFailed? .call (failedState),
706
778
DeletingFailed () => deletingFailed? .call (failedState),
707
779
};
708
780
0 commit comments