Skip to content

Commit

Permalink
Add regression test for #1463.
Browse files Browse the repository at this point in the history
Fix #1463.
  • Loading branch information
munificent committed Aug 5, 2024
1 parent ed3c5c6 commit 8906a9c
Showing 1 changed file with 149 additions and 0 deletions.
149 changes: 149 additions & 0 deletions test/tall/regression/1400/1463.unit
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
>>>
class C {
late final Command<MessageUpdateRequest, void> addNewMessageCommand =
Command.createAsyncNoResult<MessageUpdateRequest>((newMessage) async {
final chatApi = ChatsApi(di<ApiClient>());
if (_target == null) {
assert(_chatPartner != null);
_target = await chatApi.sendMessageToUserAndCreateChatIfNeeded(
_chatPartner!.id.toString(),
messageUpdateRequest: newMessage);
} else {
await chatApi.addMessageToChat(chatId, messageUpdateRequest: newMessage);
}
notifyListeners();
},
errorFilter: ApiErrorFilter(
(error) => error.code == 412 || error.code == 403,
ErrorReaction.localHandler,
),debugName: cmdAddMessage)
..errors.listen((ex,_) {
final apiError = ex!.error as ApiException;

/// TODO adjust to chatmessagesource
items.removeLast();
lastMessage = null;
refreshItemCOunt();
if (apiError.message?.contains('limited to 15 people') ?? false) {
di<InteractionManager>().pushToastWithBuilder(
(context) => ToastConfig(
context.l10n.messagingLimitPerDay,
),
);
} else if (apiError.message?.contains('Permission denied') ?? false) {
di<InteractionManager>().pushToastWithBuilder(
(context) => ToastConfig(
context.l10n.defaultMessagingRestriction,
),
);
}
});
}
<<<
class C {
late final Command<MessageUpdateRequest, void> addNewMessageCommand =
Command.createAsyncNoResult<MessageUpdateRequest>(
(newMessage) async {
final chatApi = ChatsApi(di<ApiClient>());
if (_target == null) {
assert(_chatPartner != null);
_target =
await chatApi.sendMessageToUserAndCreateChatIfNeeded(
_chatPartner!.id.toString(),
messageUpdateRequest: newMessage,
);
} else {
await chatApi.addMessageToChat(
chatId,
messageUpdateRequest: newMessage,
);
}
notifyListeners();
},
errorFilter: ApiErrorFilter(
(error) => error.code == 412 || error.code == 403,
ErrorReaction.localHandler,
),
debugName: cmdAddMessage,
)
..errors.listen((ex, _) {
final apiError = ex!.error as ApiException;

/// TODO adjust to chatmessagesource
items.removeLast();
lastMessage = null;
refreshItemCOunt();
if (apiError.message?.contains('limited to 15 people') ?? false) {
di<InteractionManager>().pushToastWithBuilder(
(context) => ToastConfig(context.l10n.messagingLimitPerDay),
);
} else if (apiError.message?.contains('Permission denied') ?? false) {
di<InteractionManager>().pushToastWithBuilder(
(context) => ToastConfig(
context.l10n.defaultMessagingRestriction,
),
);
}
});
}
>>>
class C {
late final Command<MessageUpdateRequest, void> addNewMessageCommand =
Command.createAsyncNoResult<MessageUpdateRequest>(_addNewMessage,
errorFilter: ApiErrorFilter(
(error) => error.code == 412 || error.code == 403,
ErrorReaction.localHandler,
),debugName: cmdAddMessage)
..errors.listen((ex,_) {
final apiError = ex!.error as ApiException;

/// TODO adjust to chatmessagesource
items.removeLast();
lastMessage = null;
refreshItemCOunt();
if (apiError.message?.contains('limited to 15 people') ?? false) {
di<InteractionManager>().pushToastWithBuilder(
(context) => ToastConfig(
context.l10n.messagingLimitPerDay,
),
);
} else if (apiError.message?.contains('Permission denied') ?? false) {
di<InteractionManager>().pushToastWithBuilder(
(context) => ToastConfig(
context.l10n.defaultMessagingRestriction,
),
);
}
});
}
<<<
class C {
late final Command<MessageUpdateRequest, void> addNewMessageCommand =
Command.createAsyncNoResult<MessageUpdateRequest>(
_addNewMessage,
errorFilter: ApiErrorFilter(
(error) => error.code == 412 || error.code == 403,
ErrorReaction.localHandler,
),
debugName: cmdAddMessage,
)
..errors.listen((ex, _) {
final apiError = ex!.error as ApiException;

/// TODO adjust to chatmessagesource
items.removeLast();
lastMessage = null;
refreshItemCOunt();
if (apiError.message?.contains('limited to 15 people') ?? false) {
di<InteractionManager>().pushToastWithBuilder(
(context) => ToastConfig(context.l10n.messagingLimitPerDay),
);
} else if (apiError.message?.contains('Permission denied') ?? false) {
di<InteractionManager>().pushToastWithBuilder(
(context) => ToastConfig(
context.l10n.defaultMessagingRestriction,
),
);
}
});
}

0 comments on commit 8906a9c

Please sign in to comment.