Skip to content

Commit

Permalink
Feed abstract: Inherit font size
Browse files Browse the repository at this point in the history
And fix some code style.

Closes zotero#4600
  • Loading branch information
AbeJellinek committed Aug 21, 2024
1 parent 182bfb9 commit f8970b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion chrome/content/zotero/actors/FeedAbstractChild.jsm
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
var EXPORTED_SYMBOLS = ["FeedAbstractChild"];

var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

class FeedAbstractChild extends JSWindowActorChild {
_stylesheet;

_stylesheetPromise;

actorCreated() {
this._stylesheetPromise = this.sendQuery('getStylesheet');
this._stylesheetPromise = this.sendQuery("getStylesheet");
Services.prefs.addObserver("extensions.zotero.fontSize", this._setFontSize);
}

didDestroy() {
Services.prefs.removeObserver("extensions.zotero.fontSize", this._setFontSize);
}

async receiveMessage({ name, data: { url, html } }) {
Expand All @@ -17,6 +23,7 @@ class FeedAbstractChild extends JSWindowActorChild {
base.href = url;
this.document.head.replaceChildren(base);
this.document.body.innerHTML = html;
this._setFontSize();
break;
}
}
Expand Down Expand Up @@ -51,4 +58,9 @@ class FeedAbstractChild extends JSWindowActorChild {

this.document.wrappedJSObject.adoptedStyleSheets.push(this._stylesheet);
}

_setFontSize = () => {
let fontSize = Services.prefs.getStringPref("extensions.zotero.fontSize");
this.document.body.style.fontSize = fontSize + "rem";
};
}
4 changes: 2 additions & 2 deletions chrome/content/zotero/actors/FeedAbstractParent.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class FeedAbstractParent extends JSWindowActorParent {
async receiveMessage({ name, data }) {
switch (name) {
case "getStylesheet": {
return Zotero.File.getResourceAsync('chrome://zotero/skin/feedAbstract.css');
return Zotero.File.getResourceAsync("chrome://zotero/skin/feedAbstract.css");
}

case "resize": {
this._resizeBrowser(data.offsetHeight);
return;
return undefined;
}
}
}
Expand Down

0 comments on commit f8970b9

Please sign in to comment.