Skip to content

Commit

Permalink
create new Soup session on refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
neffo committed May 11, 2022
1 parent 390a709 commit 215a649
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,7 @@ class BingWallpaperIndicator extends PanelMenu.Button {
// take a variety of actions when the gsettings values are modified by prefs
this._settings = ExtensionUtils.getSettings(Utils.BING_SCHEMA);

this.httpSession = new Soup.Session();
Soup.Session.prototype.add_feature.call(this.httpSession, new Soup.ProxyResolverDefault()); // unclear if this is necessary
if (this._settings.get_boolean('debug-logging')) {
this.logger = Soup.Logger.new(Soup.LoggerLogLevel.HEADERS, -1);
this.logger.attach(this.httpSession);
this.logger.set_printer(soupPrinter);
}
this._initSoup();

getActorCompat(this).visible = !this._settings.get_boolean('hide');

Expand Down Expand Up @@ -218,6 +212,16 @@ class BingWallpaperIndicator extends PanelMenu.Button {
}
}

_initSoup() {
this.httpSession = new Soup.Session();
Soup.Session.prototype.add_feature.call(this.httpSession, new Soup.ProxyResolverDefault()); // unclear if this is necessary
if (this._settings.get_boolean('debug-logging')) {
this.logger = Soup.Logger.new(Soup.LoggerLogLevel.HEADERS, -1);
this.logger.attach(this.httpSession);
this.logger.set_printer(soupPrinter);
}
}

// listen for configuration changes
_setConnections() {
this._settings.connect('changed::hide', () => {
Expand Down Expand Up @@ -487,6 +491,7 @@ class BingWallpaperIndicator extends PanelMenu.Button {
this._updatePending = true;
this._restartTimeout();
let market = this._settings.get_string('market');
this._initSoup(); // get new session, incase we aren't detecting proxy changes
// create an http message
let url = BingImageURL + (market != 'auto' ? market : '');
let request = Soup.Message.new('GET', url);
Expand Down

0 comments on commit 215a649

Please sign in to comment.