Skip to content

Commit

Permalink
[v1.3.2] Fix slider in context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
GriefMoDz committed Mar 5, 2023
1 parent dd77613 commit 6eac136
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"discordID": "350227339784880130",
"github": "griefmodz"
},
"version": "1.3.1",
"version": "1.3.2",
"updater": {
"type": "github",
"id": "griefmodz/statistic-counter"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "statistic-counter",
"version": "1.3.1",
"version": "1.3.2",
"description": "A Replugged plug-in that has been ported from Powercord which introduces an interchangeable statistic counter in-between the home button and servers list.",
"engines": {
"node": ">=14.0.0"
Expand Down Expand Up @@ -31,7 +31,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-react": "^7.31.10",
"prettier": "^2.8.1",
"replugged": "4.0.0-beta0.27",
"replugged": "4.0.0",
"typescript": "^4.8.4"
}
}
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions src/components/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@ import { common, components, util, webpack } from 'replugged';
import { prefs } from '@index';

import CounterStore from '@lib/store';
import ErrorBoundary from './ErrorBoundary';

const { React, fluxDispatcher } = common;
const { ContextMenu } = components;
const { Messages } = common.i18n;

const SliderControl = await webpack.waitForModule<typeof Slider>(webpack.filters.bySource('sliderContainer'));
const SliderControl = await webpack
.waitForModule<typeof Slider>(webpack.filters.bySource('sliderContainer,'))
.then((mod) => Object.values(mod).find((mod) => mod?.render?.toString?.().includes('sliderContainer')));

function CounterItems(): React.ReactElement[] {
return Object.keys(Counters).map((key) => {
const items: React.ReactElement[] = [];

for (const key in Counters) {
const counter = key as CounterType;
const counterName = Messages[Counters[counter].translationKey];
const currentState = util.useSetting(prefs, counter);

return (
items.push(
<ContextMenu.MenuCheckboxItem
id={`show-${counter}`}
label={Messages.STATISTIC_COUNTER_SHOW_COUNTER.format({ counter: counterName })}
Expand All @@ -43,7 +48,9 @@ function CounterItems(): React.ReactElement[] {
}}
/>
);
});
}

return items;
}

function VisibilityItems(): React.ReactElement {
Expand Down Expand Up @@ -130,7 +137,9 @@ function ContextMenuItems(): React.ReactElement {
}

export default React.memo((props) => (
<ContextMenu.ContextMenu navId='statistic-counter-context-menu' {...props}>
{ContextMenuItems()}
</ContextMenu.ContextMenu>
<ErrorBoundary>
<ContextMenu.ContextMenu navId='statistic-counter-context-menu' {...props}>
{ContextMenuItems()}
</ContextMenu.ContextMenu>
</ErrorBoundary>
));

0 comments on commit 6eac136

Please sign in to comment.