HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //proc/thread-self/root/var/www/html/wpwatermates/wp-content/plugins/chaty/src/modules/channels.js
const $ = window.jQuery;
export default function channels() {
    /**
     * bring the newly created channel settings into view 
     */ 
    function bringNewChannelIntoView( target ) {
        const $scope =  $(`#chaty-social-${target}`);
        $scope[0].scrollIntoView({
            behavior: "smooth",
            block: "center"
        })
    }

    /**
     * show pro alert when users tries to use more than 2 channel 
     */ 
    function onChannelLimitExceeded( isExceeded ) {
        const $popover = $('.popover-upgrade-pro');
        if( isExceeded ) {
            // show and shake
            $popover.addClass('flex shake-it').removeClass('hidden');
            // scroll into view
            if( !$popover.isInViewport() ) {
                $popover[0].scrollIntoView({
                    behavior: "smooth",
                    block: "center"
                })
            }
            setTimeout(() =>  $popover.removeClass('shake-it'), 1000);
        } else {
            $popover.removeClass('flex shake-it').addClass('hidden');
        }
    }
    
    /**
     * channel update handler 
     */ 
    function init( props ) {
        const { action, target, channel, isExceeded } = props;
        onChannelLimitExceeded( isExceeded  );

        if( action === 'added' && !isExceeded && target ) {
            bringNewChannelIntoView( target );
        }

        /**
         * If just one channel is selected, 
         * then widget icon, color, default state, and icons view shouldn't appear in steps 2 and 3 
         */ 
        {
            const status = channel.length <= 1 // true | false;
            $('.chaty-widget-color, .chaty-widget-icon, .chaty-default-state, .chaty-icon-view').toggleClass('hidden', status);
        }

    }

    wp.hooks.addAction('chaty.channel_update', 'channelUpdateHandler', init)
}

// call when any channel is removed or updated
// const channel_list = [];
// jQuery('.channels-icons > .icon.active').each( (i, item) => {
//     channel_list.push( item.dataset.social );
// } )
// wp.hooks.doAction('chaty.channel_update', {
//     channel     : channel_list,         // active channel list
//     target      : social,               // channel that removed last
//     action      : 'removed',            // added || removed,
//     isExceeded  : false,
// });