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(value: any, coursewareSid?: string): string {
    return value ? `/api/media-resource/${value}/file` : '';
    // if (isInElectron && ElectronUtil.hasCached(coursewareSid, value)) {
    //   ret = `file://${APP_PATH}/courseware_cache/${coursewareSid}/${value}`;
    // }
    // return ret;
  }

}
