How to use the mattermost-redux/utils/event_emitter.emit function in mattermost-redux

To help you get started, we’ve selected a few mattermost-redux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mattermost / mattermost-mobile / app / app.js View on Github external
let screen = 'SelectServer';
        if (this.token && this.url) {
            screen = 'Channel';
            tracker.initialLoad = Date.now();

            try {
                dispatch(loadMe());
            } catch (e) {
                // Fall through since we should have a previous version of the current user because we have a token
                console.warn('Failed to load current user when starting on Channel screen', e); // eslint-disable-line no-console
            }
        }

        switch (screen) {
        case 'SelectServer':
            EventEmitter.emit(ViewTypes.LAUNCH_LOGIN, true);
            break;
        case 'Channel':
            EventEmitter.emit(ViewTypes.LAUNCH_CHANNEL, true);
            break;
        }

        this.setAppStarted(true);
    }
}
github mattermost / mattermost-mobile / app / utils / push_notifications.js View on Github external
loadFromNotification = async (notification) => {
        // Set appStartedFromPushNotification to avoid channel screen to call selectInitialChannel
        EphemeralStore.appStartedFromPushNotification = true;
        await this.store.dispatch(loadFromPushNotification(notification));

        // if we have a componentId means that the app is already initialized
        const componentId = EphemeralStore.getNavigationTopComponentId();
        if (componentId) {
            EventEmitter.emit('close_channel_drawer');
            EventEmitter.emit('close_settings_sidebar');

            await dismissAllModals();
            await popToRoot();

            PushNotifications.resetNotification();
        }
    };
github mattermost / mattermost-mobile / app / components / post_textbox / post_textbox_base.js View on Github external
handleTextChange = (value, autocomplete = false) => {
        const {
            actions,
            channelId,
            rootId,
            cursorPositionEvent,
            valueEvent,
        } = this.props;

        if (valueEvent) {
            EventEmitter.emit(valueEvent, value);
        }

        const nextState = {value};

        // Workaround for some Android keyboards that don't play well with cursors (e.g. Samsung keyboards)
        if (autocomplete && this.input?.current) {
            if (Platform.OS === 'android') {
                RNTextInputReset.resetKeyboardInput(findNodeHandle(this.input.current));
            } else {
                nextState.cursorPosition = value.length;
                if (cursorPositionEvent) {
                    EventEmitter.emit(cursorPositionEvent, nextState.cursorPosition);
                }
            }
        }
github mattermost / mattermost-mobile / app / screens / notification / notification.js View on Github external
notificationTapped = () => {
        this.tapped = true;
        this.clearDismissTimer();

        const {actions, notification} = this.props;

        EventEmitter.emit('close_channel_drawer');
        EventEmitter.emit('close_settings_sidebar');
        InteractionManager.runAfterInteractions(() => {
            this.dismissOverlay();
            if (!notification.localNotification) {
                actions.loadFromPushNotification(notification);
            }
        });
    };
github mattermost / mattermost-webapp / components / profile_popover / profile_popover.jsx View on Github external
handleMentionKeyClick(e) {
        e.preventDefault();

        if (!this.props.user) {
            return;
        }
        if (this.props.hide) {
            this.props.hide();
        }
        EventEmitter.emit('mention_key_click', this.props.user.username, this.props.isRHS);
    }
github mattermost / mattermost-mobile / app / realm / actions / helpers.js View on Github external
export function forceLogoutIfNecessary(clientError) {
    if (clientError.status_code === HTTP_UNAUTHORIZED && clientError.url && clientError.url.indexOf('/login') === -1) {
        EventEmitter.emit(NavigationTypes.NAVIGATION_RESET);
    }
}
github mattermost / mattermost-mobile / app / screens / load_team / load_team.js View on Github external
getTeams().then(() => {
                EventEmitter.emit(NavigationTypes.NAVIGATION_NO_TEAMS);
            });
        }
github mattermost / mattermost-mobile / app / components / file_attachment_list / file_attachment_voice_message.js View on Github external
this.player.playPause((err, paused) => {
                if (paused) {
                    clearInterval(this.progressInterval);
                } else {
                    EventEmitter.emit(MediaTypes.STOP_AUDIO, this.props.file.id);
                    this.progressInterval = setInterval(this.updateProgress, 100);
                }

                if (this.mounted) {
                    this.setState({
                        error: err?.message,
                        isPlaying: !paused,
                    });
                }
            });
        }
github mattermost / mattermost-mobile / app / actions / views / channel.js View on Github external
return (dispatch, getState) => {
        const state = getState();
        const threadId = state.entities.posts.selectedPostId;

        const insertEvent = threadId ? INSERT_TO_COMMENT : INSERT_TO_DRAFT;

        EventEmitter.emit(insertEvent, value);
    };
}
github mattermost / mattermost-mobile / app / navigation / router.js View on Github external
handleDrawerTween = (ratio) => {
        const opacity = (ratio / 2);

        EventEmitter.emit('drawer_opacity', opacity);

        return {
            mainOverlay: {
                backgroundColor: this.props.theme.centerChannelBg,
                opacity
            },
            drawerOverlay: {
                backgroundColor: ratio ? '#000' : '#FFF',
                opacity: ratio ? (1 - ratio) / 2 : 1
            }
        };
    };