Skip to content

Commit

Permalink
Fix PI for latest Canary Changes
Browse files Browse the repository at this point in the history
Co-Authored-By: Kaan <[email protected]>
  • Loading branch information
domi-btnr and zrodevkaan committed Nov 3, 2024
1 parent dc6a24a commit d79c24d
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Misc
.idea
.vscode
.DS_Store

node_modules
./**/node_modules
Expand Down
55 changes: 55 additions & 0 deletions PlatformIndicators/changelog.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.Changelog-Title-Wrapper {
font-size: 20px;
font-weight: 600;
font-family: var(--font-display);
color: var(--header-primary);
line-height: 1.2;

div {
font-size: 12px;
font-weight: 400;
font-family: var(--font-primary);
color: var(--primary-300);
line-height: 1.3333333333333333;
}
}

.Changelog-Banner {
width: 405px;
border-radius: 8px;
margin-bottom: 20px;
}

.Changelog-Item {
color: #c4c9ce;

.Changelog-Header {
display: flex;
text-transform: uppercase;
font-weight: 700;
align-items: center;
margin-bottom: 10px;

&.added { color: #45BA6A; }
&.fixed { color: #EC4245; }
&.improved { color: #5865F2; }

&::after {
content: "";
flex-grow: 1;
height: 1px;
margin-left: 7px;
background: currentColor;
}
}

span {
display: list-item;
list-style: inside;
margin-left: 5px;

&::marker {
color: var(--background-accent);
}
}
}
3 changes: 2 additions & 1 deletion PlatformIndicators/components/indicators.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

&.type_Chat {
margin-right: -6px;
margin-top: 2px;
vertical-align: top;
}
}
Expand All @@ -26,7 +27,7 @@
margin-right: 2px;
padding-right: 2px;
border-right: thin solid var(--background-modifier-hover);
height: 22px;
height: 14px;
}

div[id*=message-reply] .indicatorContainer.type_Chat {
Expand Down
45 changes: 43 additions & 2 deletions PlatformIndicators/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {DOM, Patcher, ReactUtils, Webpack, Utils} from "@api";
import {DOM, Patcher, ReactUtils, Webpack, UI, Utils} from "@api";
import manifest from "@manifest";
import Styles from "@styles";
import React from "react";
import Settings from "./modules/settings";
Expand All @@ -12,6 +13,7 @@ export default class PlatformIndicators {
}

start() {
this.showChangelog();
this.patchDMs();
this.patchMemberList();
this.patchChat();
Expand All @@ -20,6 +22,44 @@ export default class PlatformIndicators {
Styles.load();
}

showChangelog() {
if (
!manifest?.changelog?.length ||
Settings.get("lastVersion") === manifest.version
) return;

const i18n = Webpack.getByKeys("getLocale");
const formatter = new Intl.DateTimeFormat(i18n.getLocale(), {
month: "long",
day: "numeric",
year: "numeric"
});

const title = (
<div className="Changelog-Title-Wrapper">
<h1>What's New - {manifest.name}</h1>
<div>{formatter.format(new Date(manifest.changelogDate))} - v{manifest.version}</div>
</div>
)

const items = manifest?.changelog?.map(item => (
<div className="Changelog-Item">
<h4 className={`Changelog-Header ${item.type}`}>{item.title}</h4>
{item.items.map(item => (
<span>{item}</span>
))}
</div>
));

"changelogImage" in manifest && items.unshift(
<img className="Changelog-Banner" src={manifest.changelogImage} />
);

Settings.set("lastVersion", manifest.version);

UI.alert(title, items);
}

patchDMs() {
const UserContext = React.createContext(null);
const [ChannelWrapper, Key_CW] = Webpack.getWithKey(Webpack.Filters.byStrings("isGDMFacepileEnabled"));
Expand Down Expand Up @@ -108,7 +148,7 @@ export default class PlatformIndicators {
patchBadges() {
const UserContext = React.createContext(null);
const [ProfileInfoRow, KEY_PIR] = Webpack.getWithKey(Webpack.Filters.byStrings("user", "profileType"));
const [BadgeList, Key_BL] = Webpack.getWithKey(Webpack.Filters.byStrings(".PROFILE_USER_BADGES"));
const [BadgeList, Key_BL] = Webpack.getWithKey(Webpack.Filters.byStrings("badges", "badgeClassName"));

Patcher.after(ProfileInfoRow, KEY_PIR, (_, [props], res) => {
if (!Settings.get("showInBadges", true)) return;
Expand All @@ -127,6 +167,7 @@ export default class PlatformIndicators {
<StatusIndicators
userId={user.id}
type="Badge"
separator
/>
);
});
Expand Down
2 changes: 1 addition & 1 deletion PlatformIndicators/modules/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const Flux = Webpack.getByKeys("Store");
export const ModulesLibrary = Webpack.getByKeys("Anchor");
export const Colors = Webpack.getByKeys("RED_400");

export const {Messages} = Webpack.getModule(m => m?.Messages?.STATUS_DND);
export const Messages = {"STATUS_DND": "Do Not Disturb", "STATUS_OFFLINE": "Offline", "STATUS_ONLINE": "Online", "STATUS_STEAMING": "Streaming", "STATUS_IDLE": "IDLE", "STATUS_MOBILE": "Mobile"};
export const buildClassName = (...args) => { // yeah, yk... I couldnt find a working string for this so I just remade it ;-;
return args.reduce((classNames, arg) => {
if (!arg) return classNames;
Expand Down
2 changes: 1 addition & 1 deletion PlatformIndicators/modules/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Utils} from "@api";
import {Messages} from "./shared";
import {Colors, ModulesLibrary, buildClassName} from "./shared";
import {Colors, ModulesLibrary} from "./shared";

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

Expand Down
15 changes: 13 additions & 2 deletions PlatformIndicators/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
{
"name": "APlatformIndicators",
"version": "1.5.9",
"version": "1.5.10",
"author": "Strencher",
"authorId": "415849376598982656",
"description": "Adds indicators for every platform that the user is using.",
"source": "https://github.com/Strencher/BetterDiscordStuff/blob/master/PlatformIndicators/APlatformIndicators.plugin.js",
"invite": "gvA2ree"
"invite": "gvA2ree",
"changelog": [
{
"title": "Fixed",
"type": "fixed",
"items": [
"Fixed Tooltip Messages",
"Fixed Badges not showing up"
]
}
],
"changelogDate": "2024-11-03"
}

0 comments on commit d79c24d

Please sign in to comment.