瀏覽代碼

MediaboxDirective: Use bufferToUrl helper directly

Danilo Bargen 6 年之前
父節點
當前提交
05734d0f1e
共有 1 個文件被更改,包括 10 次插入5 次删除
  1. 10 5
      src/directives/mediabox.ts

+ 10 - 5
src/directives/mediabox.ts

@@ -17,16 +17,17 @@
 
 import {saveAs} from 'file-saver';
 
+import {bufferToUrl, logAdapter} from '../helpers';
 import {MediaboxService} from '../services/mediabox';
 
 export default [
     '$rootScope',
-    '$filter',
     '$document',
+    '$log',
     'MediaboxService',
     function($rootScope: ng.IRootScopeService,
-             $filter: ng.IFilterService,
              $document: ng.IDocumentService,
+             $log: ng.ILogService,
              mediaboxService: MediaboxService) {
         return {
             restrict: 'E',
@@ -34,6 +35,8 @@ export default [
             bindToController: {},
             controllerAs: 'ctrl',
             controller: [function() {
+                this.logTag = '[MediaboxDirective]';
+
                 // Data attributes
                 this.imageDataUrl = null;
                 this.caption = '';
@@ -55,11 +58,13 @@ export default [
                 };
 
                 // Listen to Mediabox service events
-                const bufferToUrl = $filter('bufferToUrl') as
-                    (buffer: ArrayBuffer, mimeType: string, trust: boolean) => string;
                 mediaboxService.evtMediaChanged.attach((dataAvailable: boolean) => {
                     $rootScope.$apply(() => {
-                        this.imageDataUrl = bufferToUrl(mediaboxService.data, mediaboxService.mimetype, true);
+                        this.imageDataUrl = bufferToUrl(
+                            mediaboxService.data,
+                            mediaboxService.mimetype,
+                            logAdapter($log.debug, this.logTag),
+                        );
                         this.caption = mediaboxService.caption || mediaboxService.filename;
                     });
                 });