diff --git a/Viewer/features/core.js b/Viewer/features/core.js index 3ae84b38..dc47e1df 100755 --- a/Viewer/features/core.js +++ b/Viewer/features/core.js @@ -2366,13 +2366,35 @@ function(func){ // ExampleActions.exampleTask(..) // ExampleActions.exampleSessionTask(..) + +// +// NOTE: we can pass sync/async to this in two places, in definition: +// var action = taskAction('some title', 'sync', function(..){ .. }) +// or +// var action = taskAction('sync', 'some title', function(..){ .. }) +// +// and on call: +// action('sync', ..) +// +// during the later form 'sync' is passed to .Task(..) in the correct +// position... +// (see ig-types' runner.TaskManager(..) for more info) var taskAction = module.taskAction = function(title, func){ + var pre_args = [...arguments] + func = pre_args.pop() + title = pre_args + .filter(function(t){ + return t != 'sync' && t != 'async' }) + .pop() + var action return (action = object.mixin( Task(function(...args){ - return this.tasks.Task(title, func.bind(this), ...args) }), + if(args[0] == 'sync' || args[0] == 'async'){ + pre_args = [args.shift(), title] } + return this.tasks.Task(...pre_args, func.bind(this), ...args) }), { __task_title__: title, toString: function(){ diff --git a/Viewer/features/sharp.js b/Viewer/features/sharp.js index 3ae08093..2f2ef2f8 100755 --- a/Viewer/features/sharp.js +++ b/Viewer/features/sharp.js @@ -861,8 +861,7 @@ module.Sharp = core.ImageGridFeatures.Feature({ // XXX this is best done in a thread + needs to be abortable (on .load(..))... [['loadImages', 'loadNewImages'], - function(){ - this.cacheMetadata('all') }], + 'cacheMetadata: "all"'], //*/ // set orientation if not defined... @@ -879,8 +878,11 @@ module.Sharp = core.ImageGridFeatures.Feature({ var that = this // NOTE: as this directly affects the visible lag, this // must be as fast as possible... + // NOTE: running .cacheMetadata(..) in sync mode here forces + // the image to update before it gets a change to be + // drawn... ;((this.images[gid] || {}).metadata || {}).ImageGridMetadata - || this.cacheMetadata(gid, false) + || this.cacheMetadata('sync', gid, false) .then(function([res]){ res && that.logger diff --git a/Viewer/package-lock.json b/Viewer/package-lock.json index 7795db28..16d9be8d 100755 --- a/Viewer/package-lock.json +++ b/Viewer/package-lock.json @@ -1110,9 +1110,9 @@ "integrity": "sha512-9kZM80Js9/eTwXN9VXwLDC1wDJ7gIAdYU9GIzb5KJmNcLAMaW+zhgFrwFFMrcSfggUuadgnqSrS41E4XLe8JZw==" }, "ig-types": { - "version": "5.0.17", - "resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.17.tgz", - "integrity": "sha512-A4qzL3t+usOnPx7tu+ieUDQIDUBEocouv7O6aBbLTcleDM5VNDOrdswfThNk3PSoP1bTSLmQV9LWsBRG1qVXiA==", + "version": "5.0.18", + "resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.18.tgz", + "integrity": "sha512-8c16slG/J0qC9oYW1Mx6oSriEYKEY/HLs4SvgWDLqac/qx/nMaa6HlEUA/fi+whGxvTk03t4s/IKca+MKWV9oQ==", "requires": { "ig-object": "^5.4.12", "object-run": "^1.0.1" diff --git a/Viewer/package.json b/Viewer/package.json index 50cdb31a..a6ab2f98 100755 --- a/Viewer/package.json +++ b/Viewer/package.json @@ -32,7 +32,7 @@ "ig-argv": "^2.15.0", "ig-features": "^3.4.2", "ig-object": "^5.4.12", - "ig-types": "^5.0.17", + "ig-types": "^5.0.18", "moment": "^2.29.1", "object-run": "^1.0.1", "requirejs": "^2.3.6",