From c2ba38323419cae998d50cc2aeeca73d6bbfafce Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Tue, 27 Feb 2024 14:19:24 -0300 Subject: [PATCH] chore: add emitErrorCreateDirectMessage helper function --- .../helpers/emitErrorCreateDirectMessage.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 app/lib/methods/helpers/emitErrorCreateDirectMessage.ts diff --git a/app/lib/methods/helpers/emitErrorCreateDirectMessage.ts b/app/lib/methods/helpers/emitErrorCreateDirectMessage.ts new file mode 100644 index 000000000..a9779a95d --- /dev/null +++ b/app/lib/methods/helpers/emitErrorCreateDirectMessage.ts @@ -0,0 +1,15 @@ +import { LISTENER } from '../../../containers/Toast'; +import i18n from '../../../i18n'; +import EventEmitter from './events'; +import log from './log'; + +export const emitErrorCreateDirectMessage = (e: any): void => { + if (e?.errorType === 'error-not-allowed') { + if (e?.details?.method === 'createDirectMessage') + EventEmitter.emit(LISTENER, { + message: i18n.t('error-action-not-allowed', { action: i18n.t('Create_Direct_Messages') }) + }); + } else { + log(e); + } +};