import { checkNewQuestions } from './checkNewQuestions' ; import { assignState } from './state' ; export const watchNewQuestions = ( channel , speakInterface ) => { assignState ( { channel } ) ; new MutationObserver ( ( _ , observer ) => { if ( speakInterface . textContent === 'Use more recent newest tab' ) { observer . disconnect ( ) ; return ; } const newPostActivity = document . querySelector < HTMLElement > ( '.js-new-post-activity' ) ; if ( newPostActivity ) { newPostActivity . click ( ) ; } } ) . observe ( document . querySelector ( '#questions' ) ! , { childList : true } ) ; window . $ ( document ) . ajaxComplete ( ( _event , _jqXHR , ajaxOptions ) => { if ( ajaxOptions && ajaxOptions . url && ajaxOptions . url . startsWith ( '/posts/ajax-load-realtime-list/' ) ) { checkNewQuestions ( ) ; } } ) ; } ;