Skip to content

Commit

Permalink
[v1.3.1] Use waitForProps and conform with new standards
Browse files Browse the repository at this point in the history
  • Loading branch information
GriefMoDz committed Feb 12, 2023
1 parent 29bdbb4 commit dd77613
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Formally known as "Online Friends Count", this is a Replugged plug-in that has b

![License: MIT](https://img.shields.io/github/license/griefmodz/statistic-counter?color=3ba55c&style=for-the-badge)
![Total Downloads](https://img.shields.io/github/downloads/griefmodz/statistic-counter/total?color=3ba55c&style=for-the-badge)
[![Install in Replugged](https://img.shields.io/badge/Quick%20Install-via%20RPC-3ba55c?style=for-the-badge&logo=none)](https://replugged.dev/install?identifier=griefmodz/statistic-counter&source=github)

## Features

Expand Down
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.0",
"version": "1.3.1",
"updater": {
"type": "github",
"id": "griefmodz/statistic-counter"
Expand Down
5 changes: 3 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.0",
"version": "1.3.1",
"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 All @@ -21,6 +21,7 @@
"author": "",
"license": "MIT",
"devDependencies": {
"@types/react": "^18.0.28",
"@types/node": "^18.11.2",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.40.1",
Expand All @@ -30,7 +31,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-react": "^7.31.10",
"prettier": "^2.8.1",
"replugged": "4.0.0-beta0.25",
"replugged": "4.0.0-beta0.27",
"typescript": "^4.8.4"
}
}
30 changes: 26 additions & 4 deletions pnpm-lock.yaml

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

14 changes: 5 additions & 9 deletions src/components/Counter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ import { ActionTypes, Counters } from '@lib/constants';

const FluxDispatcher = common.fluxDispatcher;

const { getExportsForProps } = webpack;
const { Messages } = common.i18n;

const RelationshipStore = await webpack.waitForModule<RelationshipStore>(webpack.filters.byProps('getRelationships'));
const PresenceStore = await webpack.waitForModule<PresenceStore>(webpack.filters.byProps('isMobileOnline'));
const GuildAvailabilityStore = await webpack.waitForModule<GuildAvailabilityStore>(webpack.filters.byProps('totalGuilds'));

const RelationshipTypes = (await webpack
.waitForModule<{ [key: number]: string }>(webpack.filters.byProps('IMPLICIT'))
.then((mod) => getExportsForProps(mod, ['IMPLICIT']))) as Record<string, string | number>;
const RelationshipTypes = (await webpack.waitForProps('IMPLICIT')) as Record<string, string | number>;
const RelationshipStore: RelationshipStore = await webpack.waitForProps(['getRelationships']);
const PresenceStore: PresenceStore = await webpack.waitForProps(['isMobileOnline']);
const GuildAvailabilityStore: GuildAvailabilityStore = await webpack.waitForProps(['totalGuilds']);

function getRelationshipCounts(): RelationshipCounts {
const relationshipTypes = Object.keys(RelationshipTypes).filter((type) => isNaN(Number(type)));
Expand All @@ -43,7 +39,7 @@ function getRelationshipCounts(): RelationshipCounts {

const IntervalWrapper: IntervalWrapper = webpack.getBySource<ModuleExports & IntervalWrapper>(/defaultProps={disable:!1,pauseOnHover:!1}/)!;
const useStateFromStoresMod = await webpack.waitForModule<ObjectExports>(webpack.filters.bySource('useStateFromStores'));
const useStateFromStores: UseStateFromStores = webpack.getFunctionBySource('useStateFromStores', useStateFromStoresMod)!;
const useStateFromStores: UseStateFromStores = webpack.getFunctionBySource(useStateFromStoresMod, 'useStateFromStores')!;

function Counter(props: { preview?: boolean }): React.ReactElement {
const { activeCounter, nextCounter, counters, settings }: CounterState = useStateFromStores(
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Counter, Settings } from '@components';
export { Settings };

export async function start(): Promise<void> {
classes.guildClasses = await webpack.waitForModule<GuildClasses>(webpack.filters.byProps('guilds', 'sidebar'));
classes.guildClasses = await webpack.waitForProps<string, GuildClasses>(['guilds', 'sidebar']);

i18n.loadAllStrings(translations);

Expand Down

0 comments on commit dd77613

Please sign in to comment.