@@ -103,9 +103,11 @@ extension MessageStateX on MessageState {
103103
104104 /// Returns true if the message is in failed updating state.
105105 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+ };
109111 }
110112
111113 /// Returns true if the message is in failed deleting state.
@@ -182,6 +184,46 @@ sealed class MessageState with _$MessageState {
182184 );
183185 }
184186
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+
185227 /// Sending state when the message is being sent.
186228 static const sending = MessageState .outgoing (
187229 state: OutgoingState .sending (),
@@ -222,16 +264,6 @@ sealed class MessageState with _$MessageState {
222264 state: CompletedState .deleted (hard: true ),
223265 );
224266
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-
235267 /// Deleting failed state when the message fails to be soft deleted.
236268 static const softDeletingFailed = MessageState .failed (
237269 state: FailedState .deletingFailed (),
@@ -285,10 +317,22 @@ sealed class CompletedState with _$CompletedState {
285317@freezed
286318sealed class FailedState with _$FailedState {
287319 /// 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 ;
289324
290325 /// 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 ;
292336
293337 /// Deleting failed state when the message fails to be deleted.
294338 const factory FailedState .deletingFailed ({
@@ -616,45 +660,66 @@ extension FailedStatePatternMatching on FailedState {
616660 /// @nodoc
617661 @optionalTypeArgs
618662 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,
621668 required TResult Function (bool hard) deletingFailed,
622669 }) {
623670 final failedState = this ;
624671 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),
627678 DeletingFailed () => deletingFailed (failedState.hard),
628679 };
629680 }
630681
631682 /// @nodoc
632683 @optionalTypeArgs
633684 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,
636690 TResult ? Function (bool hard)? deletingFailed,
637691 }) {
638692 final failedState = this ;
639693 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),
642700 DeletingFailed () => deletingFailed? .call (failedState.hard),
643701 };
644702 }
645703
646704 /// @nodoc
647705 @optionalTypeArgs
648706 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,
651712 TResult Function (bool hard)? deletingFailed,
652713 required TResult orElse (),
653714 }) {
654715 final failedState = this ;
655716 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),
658723 DeletingFailed () => deletingFailed? .call (failedState.hard),
659724 };
660725
@@ -666,12 +731,15 @@ extension FailedStatePatternMatching on FailedState {
666731 TResult map <TResult extends Object ?>({
667732 required TResult Function (SendingFailed value) sendingFailed,
668733 required TResult Function (UpdatingFailed value) updatingFailed,
734+ required TResult Function (PartialUpdatingFailed value)
735+ partialUpdatingFailed,
669736 required TResult Function (DeletingFailed value) deletingFailed,
670737 }) {
671738 final failedState = this ;
672739 return switch (failedState) {
673740 SendingFailed () => sendingFailed (failedState),
674741 UpdatingFailed () => updatingFailed (failedState),
742+ PartialUpdatingFailed () => partialUpdatingFailed (failedState),
675743 DeletingFailed () => deletingFailed (failedState),
676744 };
677745 }
@@ -681,12 +749,14 @@ extension FailedStatePatternMatching on FailedState {
681749 TResult ? mapOrNull <TResult extends Object ?>({
682750 TResult ? Function (SendingFailed value)? sendingFailed,
683751 TResult ? Function (UpdatingFailed value)? updatingFailed,
752+ TResult ? Function (PartialUpdatingFailed value)? partialUpdatingFailed,
684753 TResult ? Function (DeletingFailed value)? deletingFailed,
685754 }) {
686755 final failedState = this ;
687756 return switch (failedState) {
688757 SendingFailed () => sendingFailed? .call (failedState),
689758 UpdatingFailed () => updatingFailed? .call (failedState),
759+ PartialUpdatingFailed () => partialUpdatingFailed? .call (failedState),
690760 DeletingFailed () => deletingFailed? .call (failedState),
691761 };
692762 }
@@ -696,13 +766,15 @@ extension FailedStatePatternMatching on FailedState {
696766 TResult maybeMap <TResult extends Object ?>({
697767 TResult Function (SendingFailed value)? sendingFailed,
698768 TResult Function (UpdatingFailed value)? updatingFailed,
769+ TResult Function (PartialUpdatingFailed value)? partialUpdatingFailed,
699770 TResult Function (DeletingFailed value)? deletingFailed,
700771 required TResult orElse (),
701772 }) {
702773 final failedState = this ;
703774 final result = switch (failedState) {
704775 SendingFailed () => sendingFailed? .call (failedState),
705776 UpdatingFailed () => updatingFailed? .call (failedState),
777+ PartialUpdatingFailed () => partialUpdatingFailed? .call (failedState),
706778 DeletingFailed () => deletingFailed? .call (failedState),
707779 };
708780
0 commit comments