import { Container } from './libs/container' ; import { GitLabTree } from './main' ; import { CSS_PREFIX } from './constants' ; import { SettingsStore } from './settings.store' ; let container = new Container ( ) ; let interval ; /**
 * This is for fake AJAX re-renders of the page.
 */ function checkSiteChange ( ) { let files = document . querySelector ( '.files' ) ; if ( files && ! files . classList . contains ( CSS_PREFIX ) ) { container . destruct ( ) ; container = getInstance ( ) ; startCheckInterval ( 3000 ) ; } } function startCheckInterval ( time ) { clearInterval ( interval ) ; interval = setInterval ( ( ) => checkSiteChange ( ) , time ) ; } function getInstance ( callback = ( ) => { } ) { const container = new Container ( ) ; const settingsStore = container . get ( SettingsStore ) ; settingsStore . onceReady . then ( ( ) => { container . get ( GitLabTree ) ; callback ( ) ; } ) ; return container ; } ( ( ) => { const isGitLab = document . querySelector ( 'meta[content="GitLab"]' ) ; if ( ! isGitLab ) { return ; } container = getInstance ( ( ) => startCheckInterval ( 150 ) ) ; } ) ( ) ;