diff --git a/test/tall/regression/1400/1463.unit b/test/tall/regression/1400/1463.unit new file mode 100644 index 00000000..3ae5748b --- /dev/null +++ b/test/tall/regression/1400/1463.unit @@ -0,0 +1,149 @@ +>>> +class C { + late final Command addNewMessageCommand = + Command.createAsyncNoResult((newMessage) async { + final chatApi = ChatsApi(di()); + 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().pushToastWithBuilder( + (context) => ToastConfig( + context.l10n.messagingLimitPerDay, + ), + ); + } else if (apiError.message?.contains('Permission denied') ?? false) { + di().pushToastWithBuilder( + (context) => ToastConfig( + context.l10n.defaultMessagingRestriction, + ), + ); + } + }); +} +<<< +class C { + late final Command addNewMessageCommand = + Command.createAsyncNoResult( + (newMessage) async { + final chatApi = ChatsApi(di()); + 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().pushToastWithBuilder( + (context) => ToastConfig(context.l10n.messagingLimitPerDay), + ); + } else if (apiError.message?.contains('Permission denied') ?? false) { + di().pushToastWithBuilder( + (context) => ToastConfig( + context.l10n.defaultMessagingRestriction, + ), + ); + } + }); +} +>>> +class C { + late final Command addNewMessageCommand = + Command.createAsyncNoResult(_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().pushToastWithBuilder( + (context) => ToastConfig( + context.l10n.messagingLimitPerDay, + ), + ); + } else if (apiError.message?.contains('Permission denied') ?? false) { + di().pushToastWithBuilder( + (context) => ToastConfig( + context.l10n.defaultMessagingRestriction, + ), + ); + } + }); +} +<<< +class C { + late final Command addNewMessageCommand = + Command.createAsyncNoResult( + _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().pushToastWithBuilder( + (context) => ToastConfig(context.l10n.messagingLimitPerDay), + ); + } else if (apiError.message?.contains('Permission denied') ?? false) { + di().pushToastWithBuilder( + (context) => ToastConfig( + context.l10n.defaultMessagingRestriction, + ), + ); + } + }); +} \ No newline at end of file