import {Pipe, PipeTransform} from '@angular/core';
// import {ElectronUtil} from '../util/ElectronUtil';

declare const APP_PATH;
// const isInElectron = localStorage.getItem('electron');

@Pipe({
  name: 'resource'
})
export class ResourcePipe implements PipeTransform {

  transform(pic_url: any, coursewareSid?: string): string {
    // return pic_url;
    if (pic_url &&  typeof pic_url === 'object') {
      return pic_url;
    }
    // console.log('resource', pic_url)
    return `${pic_url}?t=${Math.random()}`;

    // let ret = value ? `/api/resource/${value}/file` : '';
    // let ret = res_id ? `/resource/audio/${res_id}` : '';
    // if (isInElectron && ElectronUtil.hasCached(coursewareSid, res_id)) {
    //   ret = `file://${APP_PATH}/courseware_cache/${coursewareSid}/${res_id}`;
    // }
    // return ret;
  }

}
