Fixing issues with hotkeys and presets

This commit is contained in:
Bruno Alves de Faria 2017-09-19 09:38:05 -03:00
parent 29a8a3db8f
commit e93c18c28f
2 changed files with 11 additions and 13 deletions

View File

@ -80,7 +80,8 @@ export class HotkeysManager {
return new Promise((resolve, reject) => {
const context = this.getContext(contextName);
if (!context) return;
this.retrieve(contextName).then(definitions => {
this.retrieve(contextName).then(defs => {
const definitions = defs || this.defaults[contextName];
if (!definitions) {
this.changeObserver.changed();
return reject();

View File

@ -121,24 +121,22 @@ class WindowLevelPresetsManager {
}
store(wlPresets) {
const self = this;
return new Promise((resolve, reject) => {
if (self.storeFunction) {
self.storeFunction(wlPresets).then(resolve).catch(reject);
if (this.storeFunction) {
this.storeFunction.call(this, wlPresets).then(resolve).catch(reject);
} else if (Meteor.userId()) {
OHIF.user.setData(WL_STORAGE_KEY, wlPresets).then(resolve).catch(reject);
} else {
Session.setPersistent(WL_STORAGE_KEY, wlPresets);
resolve();
}
}).then(() => self.setOHIFWLPresets(wlPresets));
}).then(() => this.setOHIFWLPresets.call(this, wlPresets));
}
retrieve() {
const self = this;
return new Promise((resolve, reject) => {
if (self.retrieveFunction) {
self.retrieveFunction().then(resolve).catch(reject);
if (this.retrieveFunction) {
this.retrieveFunction.call(this).then(resolve).catch(reject);
} else if (OHIF.user) {
try {
resolve(OHIF.user.getData(WL_STORAGE_KEY));
@ -152,15 +150,14 @@ class WindowLevelPresetsManager {
}
load() {
const self = this;
return new Promise((resolve, reject) => {
self.retrieve().then(wlPresets => {
this.retrieve().then(wlPresets => {
if (wlPresets) {
self.setOHIFWLPresets(wlPresets);
this.setOHIFWLPresets.call(this, wlPresets);
} else {
self.loadDefaults();
this.loadDefaults.call(this);
}
}).catch(self.loadDefaults);
}).catch(() => this.loadDefaults.call(this));
});
}