import { shell } from '../shell' export interface IntercomSettings { [key: string]: any language_override?: string module?: string admin_version?: string name?: string email?: string } const TIMEOUT = 2000 export async function intercomPoll(f: () => void) { let retries = 5 while (retries) { if (typeof shell.Intercom !== 'function') { retries -= 1 // We need to disable the following line because // we want this promise to be blocking. Otherwise // we would immediately check for the shell.Intercom // function without possibly giving it time to initialize. // eslint-disable-next-line no-await-in-loop await new Promise(resolve => setTimeout(resolve, TIMEOUT)) continue } f() break } }