Skip to content

Commit

Permalink
Move loading cookie to browser level
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 28, 2018
1 parent f0d2c96 commit 9ae29b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 11 additions & 2 deletions src/JBrowse/Browser.js
Expand Up @@ -2174,6 +2174,7 @@ _addTrackConfigs: function( /**Array*/ configs ) {
// console.warn("track with label "+conf.label+" already exists, skipping");
// return;
// }
this.loadTrackConfigFromCookie(conf);

this.trackConfigsByName[conf.label] = conf;
this.config.tracks.push( conf );
Expand All @@ -2197,7 +2198,7 @@ _replaceTrackConfigs: function( /**Array*/ newConfigs ) {

this.trackConfigsByName[conf.label] =
dojo.mixin( this.trackConfigsByName[ conf.label ] || {}, conf );
this.saveConfig(conf);
this.saveTrackConfigToCookie(conf);
},this);
},
/**
Expand Down Expand Up @@ -3427,12 +3428,20 @@ teardown: function() {
}
},

saveConfig(config) {
saveTrackConfigToCookie(config) {
const c = Object.assign({}, config)
delete c.store
delete c.menuTemplate
delete c.events
this.cookie('track-' + config.label + '-config', JSON.stringify(c));
},

loadTrackConfigFromCookie(config) {
var cookie = this.cookie("track-" + config.label + '-config');
if (cookie) {
cookie = JSON.parse(cookie)
Object.assign(config, cookie)
}
}

});
Expand Down
5 changes: 0 additions & 5 deletions src/JBrowse/View/Track/BlockBased.js
Expand Up @@ -81,11 +81,6 @@ return declare( [Component,DetailsMixin,FeatureFiltererMixin,Destroyable],

this.refSeq = args.refSeq;
this.name = args.label || this.config.label;
var cookie = this.browser.cookie("track-" + this.name + '-config');
if (cookie) {
cookie = JSON.parse(cookie)
Object.assign(this.config, cookie)
}
this.key = args.key || this.config.key || this.name;

this._changedCallback = args.changeCallback || function(){};
Expand Down

0 comments on commit 9ae29b4

Please sign in to comment.