From b82254235204a3f0e784c623d499b2e3274a83d5 Mon Sep 17 00:00:00 2001
From: sadan4 <117494111+sadan4@users.noreply.github.com>
Date: Thu, 12 Sep 2024 01:23:43 -0400
Subject: [PATCH 01/18] BetterFolders: Fix pending clan applications (#2867)
---
src/plugins/betterFolders/README.md | 11 ++++++++
src/plugins/betterFolders/index.tsx | 39 +++++++++++++++++++----------
2 files changed, 37 insertions(+), 13 deletions(-)
create mode 100644 src/plugins/betterFolders/README.md
diff --git a/src/plugins/betterFolders/README.md b/src/plugins/betterFolders/README.md
new file mode 100644
index 00000000..658c6f1d
--- /dev/null
+++ b/src/plugins/betterFolders/README.md
@@ -0,0 +1,11 @@
+# Better Folders
+
+Better Folders offers a variety of options to improve your folder experience
+
+Always show the folder icon, regardless of if the folder is open or not
+
+Only have one folder open at a time
+
+Open folders in a sidebar:
+
+![A folder open in a separate sidebar](https://github.com/user-attachments/assets/432d3146-8091-4bae-9c1e-c19046c72947)
diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx
index 0bef0933..c2969988 100644
--- a/src/plugins/betterFolders/index.tsx
+++ b/src/plugins/betterFolders/index.tsx
@@ -30,9 +30,9 @@ enum FolderIconDisplay {
MoreThanOneFolderExpanded
}
-const GuildsTree = findLazy(m => m.prototype?.moveNextTo);
-const SortedGuildStore = findStoreLazy("SortedGuildStore");
export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore");
+const SortedGuildStore = findStoreLazy("SortedGuildStore");
+const GuildsTree = findLazy(m => m.prototype?.moveNextTo);
const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand");
let lastGuildId = null as string | null;
@@ -118,17 +118,17 @@ export default definePlugin({
// If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders
{
match: /\[(\i)\]=(\(0,\i\.\i\).{0,40}getGuildsTree\(\).+?}\))(?=,)/,
- replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0].isBetterFolders,betterFoldersOriginalTree,arguments[0].betterFoldersExpandedIds)`
+ replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0]?.isBetterFolders,betterFoldersOriginalTree,arguments[0]?.betterFoldersExpandedIds)`
},
// If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children
{
match: /lastTargetNode:\i\[\i\.length-1\].+?Fragment.+?\]}\)\]/,
- replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0].isBetterFolders))"
+ replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0]?.isBetterFolders))"
},
// If we are rendering the Better Folders sidebar, we filter out everything but the scroller for the guild list from the GuildsBar Tree children
{
match: /unreadMentionsIndicatorBottom,.+?}\)\]/,
- replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0].isBetterFolders))"
+ replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0]?.isBetterFolders))"
},
// Export the isBetterFolders variable to the folders component
{
@@ -167,31 +167,31 @@ export default definePlugin({
{
predicate: () => settings.store.keepIcons,
match: /(?<=let{folderNode:\i,setNodeRef:\i,.+?expanded:(\i),.+?;)(?=let)/,
- replace: (_, isExpanded) => `${isExpanded}=!!arguments[0].isBetterFolders&&${isExpanded};`
+ replace: (_, isExpanded) => `${isExpanded}=!!arguments[0]?.isBetterFolders&&${isExpanded};`
},
// Disable expanding and collapsing folders transition in the normal GuildsBar sidebar
{
predicate: () => !settings.store.keepIcons,
match: /(?<=\.Messages\.SERVER_FOLDER_PLACEHOLDER.+?useTransition\)\()/,
- replace: "!!arguments[0].isBetterFolders&&"
+ replace: "$self.shouldShowTransition(arguments[0])&&"
},
// If we are rendering the normal GuildsBar sidebar, we avoid rendering guilds from folders that are expanded
{
predicate: () => !settings.store.keepIcons,
match: /expandedFolderBackground,.+?,(?=\i\(\(\i,\i,\i\)=>{let{key.{0,45}ul)(?<=selected:\i,expanded:(\i),.+?)/,
- replace: (m, isExpanded) => `${m}!arguments[0].isBetterFolders&&${isExpanded}?null:`
+ replace: (m, isExpanded) => `${m}$self.shouldRenderContents(arguments[0],${isExpanded})?null:`
},
{
// Decide if we should render the expanded folder background if we are rendering the Better Folders sidebar
predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always,
match: /(?<=\.wrapper,children:\[)/,
- replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0].isBetterFolders,arguments[0].betterFoldersExpandedIds)&&"
+ replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)&&"
},
{
// Decide if we should render the expanded folder icon if we are rendering the Better Folders sidebar
predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always,
match: /(?<=\.expandedFolderBackground.+?}\),)(?=\i,)/,
- replace: "!$self.shouldShowFolderIconAndBackground(!!arguments[0].isBetterFolders,arguments[0].betterFoldersExpandedIds)?null:"
+ replace: "!$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)?null:"
}
]
},
@@ -201,7 +201,7 @@ export default definePlugin({
replacement: {
// Render the Better Folders sidebar
match: /(?<=({className:\i\.guilds,themeOverride:\i})\))/,
- replace: ",$self.FolderSideBar($1)"
+ replace: ",$self.FolderSideBar({...$1})"
}
},
{
@@ -306,7 +306,20 @@ export default definePlugin({
}
},
- FolderSideBar: guildsBarProps => ,
+ shouldShowTransition(props: any) {
+ // Pending guilds
+ if (props?.folderNode?.id === 1) return true;
- closeFolders
+ return !!props?.isBetterFolders;
+ },
+
+ shouldRenderContents(props: any, isExpanded: boolean) {
+ // Pending guilds
+ if (props?.folderNode?.id === 1) return false;
+
+ return !props?.isBetterFolders && isExpanded;
+ },
+
+ FolderSideBar,
+ closeFolders,
});
From 292f7d71d3bf1ce8115bd6b7b73597ade12d0645 Mon Sep 17 00:00:00 2001
From: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
Date: Sat, 14 Sep 2024 22:59:05 +0800
Subject: [PATCH 02/18] AppleMusicRichPresence: fix metadata fetching (#2864)
---
src/plugins/appleMusic.desktop/index.tsx | 2 +-
src/plugins/appleMusic.desktop/native.ts | 80 +++++++++++++-----------
2 files changed, 46 insertions(+), 36 deletions(-)
diff --git a/src/plugins/appleMusic.desktop/index.tsx b/src/plugins/appleMusic.desktop/index.tsx
index 6fa989cd..327fafc3 100644
--- a/src/plugins/appleMusic.desktop/index.tsx
+++ b/src/plugins/appleMusic.desktop/index.tsx
@@ -120,7 +120,7 @@ const settings = definePluginSettings({
stateString: {
type: OptionType.STRING,
description: "Activity state format string",
- default: "{artist}"
+ default: "{artist} · {album}"
},
largeImageType: {
type: OptionType.SELECT,
diff --git a/src/plugins/appleMusic.desktop/native.ts b/src/plugins/appleMusic.desktop/native.ts
index 2eb2a075..7d69a85a 100644
--- a/src/plugins/appleMusic.desktop/native.ts
+++ b/src/plugins/appleMusic.desktop/native.ts
@@ -11,37 +11,11 @@ import type { TrackData } from ".";
const exec = promisify(execFile);
-// function exec(file: string, args: string[] = []) {
-// return new Promise<{ code: number | null, stdout: string | null, stderr: string | null; }>((resolve, reject) => {
-// const process = spawn(file, args, { stdio: [null, "pipe", "pipe"] });
-
-// let stdout: string | null = null;
-// process.stdout.on("data", (chunk: string) => { stdout ??= ""; stdout += chunk; });
-// let stderr: string | null = null;
-// process.stderr.on("data", (chunk: string) => { stdout ??= ""; stderr += chunk; });
-
-// process.on("exit", code => { resolve({ code, stdout, stderr }); });
-// process.on("error", err => reject(err));
-// });
-// }
-
async function applescript(cmds: string[]) {
const { stdout } = await exec("osascript", cmds.map(c => ["-e", c]).flat());
return stdout;
}
-function makeSearchUrl(type: string, query: string) {
- const url = new URL("https://tools.applemediaservices.com/api/apple-media/music/US/search.json");
- url.searchParams.set("types", type);
- url.searchParams.set("limit", "1");
- url.searchParams.set("term", query);
- return url;
-}
-
-const requestOptions: RequestInit = {
- headers: { "user-agent": "Mozilla/5.0 (Windows NT 10.0; rv:125.0) Gecko/20100101 Firefox/125.0" },
-};
-
interface RemoteData {
appleMusicLink?: string,
songLink?: string,
@@ -51,6 +25,24 @@ interface RemoteData {
let cachedRemoteData: { id: string, data: RemoteData; } | { id: string, failures: number; } | null = null;
+const APPLE_MUSIC_BUNDLE_REGEX = /