Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.

Commit

Permalink
Use arrays for status/action-bar selectors
Browse files Browse the repository at this point in the history
Fixes #8: No icon in replies on a single status page
  • Loading branch information
prplecake committed Feb 6, 2022
1 parent 03575eb commit 9ab16dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
19 changes: 16 additions & 3 deletions js/mastodon/mastopinner.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const STATUS_SELECTOR = '.item-list .status';
const STATUS_SELECTORS = [
'.item-list .status',
'.scrollable .status'
];

class MastoPinner {
constructor() {
Expand All @@ -17,7 +20,12 @@ class MastoPinner {
}

// inject the initially visible statuses
let statuses = document.querySelectorAll(STATUS_SELECTOR);
let statuses = [];
STATUS_SELECTORS.forEach((selector) => {
document.querySelectorAll(selector).forEach((s) => {
statuses.push(s);
});
});
if (statuses.length > 0) {
this._inject();
}
Expand All @@ -30,7 +38,12 @@ class MastoPinner {
}

async _inject() {
let statuses = document.querySelectorAll(STATUS_SELECTOR);
let statuses = [];
STATUS_SELECTORS.forEach((selector) => {
document.querySelectorAll(selector).forEach((s) => {
statuses.push(s);
});
});
if (statuses.length == 0) {
console.warn(`MastoPinner: couldn't inject the UI: no statuses found.`);
return;
Expand Down
6 changes: 5 additions & 1 deletion js/mastodon/mastopinner_ui.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const ACTION_BAR_SELECTORS = [
'div.status__action-bar'
];

class MastoPinnerUI {
constructor(status, { send }) {
this.status = status;
Expand All @@ -6,7 +10,7 @@ class MastoPinnerUI {
}

render() {
this.actionBar = this.status.querySelector('div.status__action-bar');
this.actionBar = this.status.querySelector(ACTION_BAR_SELECTORS);

// define node to insert
let nodeHtml = `<button id="mastopinner-button"
Expand Down

0 comments on commit 9ab16dc

Please sign in to comment.