Ejemplo n.º 1
0
 start: function () {
     this.$activities_preview = this.$('.o_mail_navbar_dropdown_channels');
     chat_manager.bus.on("activity_updated", this, this._updateCounter);
     chat_manager.is_ready.then(this._updateCounter.bind(this));
     this._updateActivityPreview();
     return this._super();
 },
Ejemplo n.º 2
0
    update_channels_preview: function () {
        var self = this;

        // Display spinner while waiting for channels preview
        this.$channels_preview.html(QWeb.render('Spinner'));

        chat_manager.is_ready.then(function () {
            var channels = _.filter(chat_manager.get_channels(), function (channel) {
                if (self.filter === 'chat') {
                    return channel.is_chat;
                } else if (self.filter === 'channels') {
                    return !channel.is_chat && channel.type !== 'static';
                } else {
                    return channel.type !== 'static';
                }
            });
            chat_manager.get_messages({channel_id: 'channel_inbox'}).then(function(result) {
                var res = [];
                _.each(result, function (message) {
                    message.unread_counter = 1;
                    var duplicatedMessage = _.findWhere(res, {model: message.model, 'res_id': message.res_id});
                    if (message.model && message.res_id && duplicatedMessage) {
                        message.unread_counter = duplicatedMessage.unread_counter + 1;
                        res[_.findIndex(res, duplicatedMessage)] = message;
                    } else {
                        res.push(message);
                    }
                });
                if (self.filter === 'channel_inbox' || !self.filter) {
                    channels = _.union(channels, res);
                }
                chat_manager.get_channels_preview(channels).then(self._render_channels_preview.bind(self));
            });
        });
    },
Ejemplo n.º 3
0
 start: function () {
     this.$filter_buttons = this.$('.o_filter_button');
     this.$channels_preview = this.$('.o_mail_navbar_dropdown_channels');
     this.filter = false;
     chat_manager.bus.on("update_channel_unread_counter", this, this.update_counter);
     chat_manager.is_ready.then(this.update_counter.bind(this));
     return this._super();
 },
Ejemplo n.º 4
0
        update_channels_preview: function () {
            var self = this;

            // Display spinner while waiting for channels preview
            this.$channels_preview.html(QWeb.render('mail.chat.Spinner'));

            chat_manager.is_ready.then(function () {
                var channels = _.filter(chat_manager.get_channels(), function (channel) {
                    if (self.filter === 'chat') {
                        return channel.is_chat;
                    } else if (self.filter === 'channels') {
                        return !channel.is_chat && channel.type !== 'static';
                    } else {
                        return channel.type !== 'static';
                    }
                });

                chat_manager.get_channels_preview(channels).then(self._render_channels_preview.bind(self));
            });
        },
Ejemplo n.º 5
0
core.bus.on('web_client_ready', null, function () {
    chat_manager.bus.on('open_chat', null, open_chat);
    chat_manager.bus.on('close_chat', null, function (channel, options) {
        var session = _.find(chat_sessions, {id: channel.id});
        if (session) {
            close_chat(session, options);
        }
    });
    chat_manager.bus.on('channel_toggle_fold', null, toggle_fold_chat);

    chat_manager.bus.on('new_message', null, function (message) {
        update_sessions(message, true);
    });

    chat_manager.bus.on('update_message', null, function (message) {
        update_sessions(message, false);
    });

    chat_manager.bus.on('anyone_listening', null, function (channel, query) {
        _.each(chat_sessions, function (session) {
            if (channel.id === session.id && session.window.thread.is_at_bottom() && !session.window.is_hidden) {
                query.is_displayed = true;
            }
        });
    });

    chat_manager.bus.on('unsubscribe_from_channel', null, function (channel_id) {
        _.each(chat_sessions, function (session) {
            if (channel_id === session.id) {
                close_chat(session);
            }
        });
    });

    chat_manager.bus.on('update_channel_unread_counter', null, function (channel) {
        display_state.hidden_unread_counter = 0;
        _.each(chat_sessions, function (session) {
            if (channel.id === session.id) {
                session.window.update_unread(channel.unread_counter);
                if (channel.unread_counter === 0) {
                    session.keep_unread = false;
                }
            }
            if (session.window.is_hidden) {
                display_state.hidden_unread_counter += session.window.unread_msgs;
            }
        });
        if (display_state.$hidden_windows_dropdown) {
            display_state.$hidden_windows_dropdown.html(render_hidden_sessions_dropdown().html());
            reposition_hidden_sessions_dropdown();
        }
    });

    chat_manager.bus.on('update_dm_presence', null, function (channel) {
        _.each(chat_sessions, function (session) {
            if (channel.id === session.id) {
                session.window.update_status(channel.status);
            }
        });
    });

    chat_manager.is_ready.then(function() {
        _.each(chat_manager.get_channels(), function (channel) {
            if (channel.is_detached) {
                open_chat(channel);
            }
        });
    });

    chat_manager.bus.on('detach_channel', null, function (channel) {
        var chat_session = _.findWhere(chat_sessions, {id: channel.id});
        if (!chat_session || chat_session.window.folded) {
            chat_manager.detach_channel(channel);
        } else if (chat_session.window.is_hidden) {
            make_session_visible(chat_session);
        } else {
            chat_session.window.focus_input();
        }
    });

    chat_manager.bus.on('client_action_open', null, function (open) {
        display_state.chat_windows_hidden = open;
        if (open) {
            $('body').addClass('o_no_chat_window');
        } else {
            $('body').removeClass('o_no_chat_window');
            reposition_windows();
        }
    });

    core.bus.on('resize', null, _.debounce(reposition_windows, 100));
});
Ejemplo n.º 6
0
 on_click: function (event) {
     event.preventDefault();
     chat_manager.is_ready.then(this.discuss_redirect.bind(this));
 },
Ejemplo n.º 7
0
 start: function () {
     this.$needaction_counter = this.$('.o_notification_counter');
     chat_manager.bus.on("update_needaction", this, this.update_counter);
     chat_manager.is_ready.then(this.update_counter.bind(this));
     return this._super();
 },