Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Commit

Permalink
Monkey patch that live state issue
Browse files Browse the repository at this point in the history
  • Loading branch information
freaktechnik committed Jul 3, 2016
1 parent 6e78db2 commit 6e9bb0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/channel/live-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class LiveState {
* The default interpretation mode based on a user's preference.
* @type {module:channel/live-state~LiveStateInterpretation}
*/
get defaultInterpretation() {
static get defaultInterpretation() {
return getDefaultInterpretation();
}
/**
Expand Down
35 changes: 16 additions & 19 deletions lib/list/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class PanelList extends EventTarget {
super(options);
this.live = new Set();
this.nonlive = new Set();
this.countNonlive = true;
this.countNonlive = LiveState.defaultInterpretation === LiveState.TOWARD_LIVE;

// Construct Buttons
this.button = new ToggleButton({
Expand All @@ -113,16 +113,16 @@ export default class PanelList extends EventTarget {
contextMenu: true,
contentURL: "./list.html",
contentScriptOptions: {
"maxHeight": prefs.panel_maxHeight,
"panelWidth": prefs.panel_minWidth,
maxHeight: prefs.panel_maxHeight,
panelWidth: prefs.panel_minWidth,
style: options.style,
extras: options.extras,
nonLiveDisplay: options.nonLiveDisplay,
theme: options.theme
},
onHide: () => {
if(this.button.state("window").checked)
this.button.state("window", {"checked": false});
this.button.state("window", {checked: false});
},
onShow: () => this.panel.port.emit("resize")
});
Expand All @@ -149,12 +149,7 @@ export default class PanelList extends EventTarget {
});

this.panel.port.on("removedLive", (id) => {
this.live.delete(id);
this.updateBadge();

if(this.live.size === 0) {
emit(this, "offline");
}
this._unregisterChannel(id);
});

sp.on("panel_badge", () => {
Expand Down Expand Up @@ -206,22 +201,24 @@ export default class PanelList extends EventTarget {

updateBadge() {
const size = this.live.size + (this.countNonlive ? this.nonlive.size : 0);
if(prefs.panel_badge && size > 0) {
this.button.badge = size;
}
else {
this.button.badge = null;
}
}
if(size > 0) {
if(prefs.panel_badge)
this.button.badge = size;
else
this.button.badge = null;

setLiveState(state) {
if(state) {
this.button.icon = liveIcons;
this.button.label = _("live_widget_label");
}
else {
this.button.badge = null;
this.button.icon = offlineIcons;
this.button.label = _("live_widget_label_offline");
}
}

setLiveState(state) {
if(!state) {
this.live.clear();
this.updateBadge();
}
Expand Down

0 comments on commit 6e9bb0b

Please sign in to comment.