Skip to content

Commit

Permalink
fixed status bar function
Browse files Browse the repository at this point in the history
  • Loading branch information
blotspot committed Dec 16, 2024
1 parent 027aace commit 3c7fcc5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jobs:
- name: Zip output
run: |
zip screen-wake-lock.zip main.js manifest.json
zip screen-wake-lock.zip main.js manifest.json styles.css
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${GITHUB_REF#refs/tags/}"
gh release create "Release $tag" \
--title="$tag" \
gh release create "$tag" \
--title="Release $tag" \
--draft \
main.js manifest.json screen-wake-lock.zip
main.js manifest.json styles.css screen-wake-lock.zip
3 changes: 2 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class WakeLockPlugin extends Plugin {
}

private updateStatusBarVisibility(showInStatusBar: boolean) {
this.statusBarItem.setVisibility(showInStatusBar);
this.statusBarItem.setVisible(showInStatusBar);
}

private async initSettings() {
Expand Down Expand Up @@ -99,6 +99,7 @@ export default class WakeLockPlugin extends Plugin {
private initStatusBar() {
this.statusBarItem = new WakeLockStatusBarItem(this.addStatusBarItem());
this.statusBarItem.addEventListener("click", this.toggleIsActive);
this.updateStatusBarVisibility(this.settings.data.showInStatusBar);
}

private onDocumentVisibilityChange = () => {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "screen-wake-lock",
"name": "Screen WakeLock",
"version": "1.0.1",
"version": "1.0.2",
"minAppVersion": "0.15.0",
"description": "Allows to keep a wake lock on the display, using the w3 WakeLock API.",
"author": "blotspot",
Expand Down
10 changes: 6 additions & 4 deletions src/statusbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const TypedEventTarget = EventTarget as {
prototype: WakeLockEventTarget;
};

const HIDE_CLASS = "screen-wake-lock-hide";

export class WakeLockStatusBarItem extends TypedEventTarget {
private el: HTMLElement;

Expand All @@ -36,11 +38,11 @@ export class WakeLockStatusBarItem extends TypedEventTarget {
this.switch(false);
}

setVisibility(visible: boolean) {
if (visible) {
this.el.style.display = "inherit";
setVisible(visible: boolean) {
if (visible && this.el.classList.contains(HIDE_CLASS)) {
this.el.classList.remove(HIDE_CLASS);
} else {
this.el.style.display = "none";
this.el.classList.add(HIDE_CLASS);
}
}

Expand Down
11 changes: 3 additions & 8 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
This CSS file will be included with your plugin, and
available in the app when your plugin is enabled.
If your plugin does not need CSS, delete this file.
*/
.screen-wake-lock-hide {
display: none;
}

0 comments on commit 3c7fcc5

Please sign in to comment.