Skip to content

Commit

Permalink
[PlatformIndicators] Fix Settings (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
zrodevkaan authored Feb 4, 2024
1 parent dd55c3d commit 9d2879d
Show file tree
Hide file tree
Showing 5 changed files with 1,479 additions and 26 deletions.
22 changes: 1 addition & 21 deletions PlatformIndicators/components/indicators.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,7 @@ import Styles from "./indicators.scss";
import {Colors, ModulesLibrary, buildClassName} from "../modules/shared";
import usePlatformStores from "../modules/usePlatformStores";
import * as Icons from "./icons/Icons";
import {getStatusText} from "../modules/utils";

function getStatusColor(status) {
const {StatusTypes} = ModulesLibrary;

switch (status) {
case StatusTypes.ONLINE:
return Colors.Color.GREEN_360;
case StatusTypes.IDLE:
return Colors.Color.YELLOW_300;
case StatusTypes.DND:
return Colors.Color.RED_400;
case StatusTypes.STREAMING:
return Colors.Color.TWITCH;
case StatusTypes.INVISIBLE:
case StatusTypes.UNKNOWN:
case StatusTypes.OFFLINE:
default:
return Colors.Color.PRIMARY_400
}
}
import {getStatusText, getStatusColor} from "../modules/utils";

export default function StatusIndicators({type, userId, size = 18, separator = false}) {
const state = usePlatformStores(userId, type);
Expand Down
3 changes: 2 additions & 1 deletion PlatformIndicators/components/settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Webpack} from "@api";
import React from "react";
import SettingsItems from "./settings.json";
import {Checkbox} from "./icons/checkbox";
import {getStatusColor} from "../modules/utils";

const {FormSwitch} = Webpack.getByKeys("FormSwitch");

Expand Down Expand Up @@ -43,7 +44,7 @@ function SmartDisable(props) {
<div key={item.id} className={Styles.item} onClick={() => handleClick(item.id)}>
{["online", "dnd", "idle", "offline"].map(status =>
React.createElement(Icons[item.icon], {
style: {color: Colors.ColorDetails[ModulesLibrary.getStatusColor(status)]?.hex},
style: {color: Colors.ColorDetails[getStatusColor(status)]?.hex},
width: iconSize,
height: iconSize
})
Expand Down
21 changes: 21 additions & 0 deletions PlatformIndicators/modules/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Utils} from "@api";
import {Messages} from "./shared";
import {Colors, ModulesLibrary, buildClassName} from "./shared";

export const findInReactTree = (tree, filter) => Utils.findInTree(tree, filter, {walkable: ["props", "children", "type"]});

Expand All @@ -8,3 +9,23 @@ function upperFirst(string) {return string.charAt(0).toUpperCase() + string.slic
export function getStatusText(key, status) {
return upperFirst(key) + ": " + Messages[`STATUS_${(status == "mobile" ? "mobile_online" : status).toUpperCase()}`];
}

export function getStatusColor(status) {
const {StatusTypes} = ModulesLibrary;

switch (status) {
case StatusTypes.ONLINE:
return Colors.Color.GREEN_360;
case StatusTypes.IDLE:
return Colors.Color.YELLOW_300;
case StatusTypes.DND:
return Colors.Color.RED_400;
case StatusTypes.STREAMING:
return Colors.Color.TWITCH;
case StatusTypes.INVISIBLE:
case StatusTypes.UNKNOWN:
case StatusTypes.OFFLINE:
default:
return Colors.Color.PRIMARY_400
}
}
7 changes: 3 additions & 4 deletions PlatformIndicators/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "APlatformIndicators",
"version": "1.5.2",
"version": "1.5.3",
"authors": [
{
"name": "Strencher",
Expand All @@ -14,14 +14,13 @@
"github_raw": "https://raw.githubusercontent.com/Strencher/BetterDiscordStuff/master/PlatformIndicators/APlatformIndicators.plugin.js",
"invite": "gvA2ree",
"changelogImage": "https://cdn.discordapp.com/attachments/672786846018961418/1053059354552696932/20th-century-fox-intro.png",
"changelogDate": "2023-12-22T09:25:34.788Z",
"changelogDate": "2024-02-04T16:25:00.000Z",
"changelog": [
{
"title": "Fixes",
"type": "fixed",
"items": [
"Crashing discord",
"I'm sorry for the delay of the fix, will work on improving this in the future."
"Settings work again (Thanks zrodevkaan)"
]
}
]
Expand Down
Loading

0 comments on commit 9d2879d

Please sign in to comment.