YouBar+: drop the slot/order customization, back to simple fixed toggles
This commit is contained in:
parent
61d47954fa
commit
886e3e5a6a
5 changed files with 48 additions and 70 deletions
|
|
@ -27,7 +27,7 @@ To install: open Discord with Revenge installed, go to **Settings → Plugins**,
|
|||
| BetterTimestamps | Revived | Calendar-relative, fully relative, ISO 8601, or a custom moment.js timestamp format, for both messages and day dividers. | `https://rp.jarviscli.dev/better-timestamps/install/` |
|
||||
| CopyRoleColor | Revived | Long-press a role pill to copy its color as hex. | `https://rp.jarviscli.dev/copy-role-color/install/` |
|
||||
| ServerDrawer | Revived | Replaces the Quest Dock with an expandable server grid - DMs, servers, folders, one-tap create/join, and mark-all-as-read, all in one drawer, with the left server rail hidden. Fork of [kmmiio99o's ServerDrawer](https://github.com/kmmiio99o/vd-plugins/tree/main/plugins/ServerDrawer) - fixed an unguarded lookup that could silently skip every patch after it, guild icons that never loaded, and drawer taps that didn't navigate. Folder options adapted from [fres621's BetterFolders](https://github.com/fres621/vendetta-plugins/tree/master/plugins/BetterFolders), rebuilt against the drawer's own folders since BetterFolders' target component no longer exists. | `https://rp.jarviscli.dev/server-drawer/install/` |
|
||||
| YouBar+ | Revived | Up to 2 configurable buttons (None/Direct Messages/Settings) on the YouBar, in your chosen order. Fork of [Purple-EyeZ's YouBar+](https://github.com/Purple-EyeZ/RevengePlugins/tree/main/plugins/YouBarPlus) - fixed a startup race condition where the button patch could silently never apply for an entire session. | `https://rp.jarviscli.dev/you-bar-plus/install/` |
|
||||
| YouBar+ | Revived | Adds DM and/or Settings buttons to the YouBar. Fork of [Purple-EyeZ's YouBar+](https://github.com/Purple-EyeZ/RevengePlugins/tree/main/plugins/YouBarPlus) - fixed a startup race condition where the button patch could silently never apply for an entire session. | `https://rp.jarviscli.dev/you-bar-plus/install/` |
|
||||
|
||||
### Productivity
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ let unpatchAll: () => void = () => {};
|
|||
|
||||
export default {
|
||||
onLoad: () => {
|
||||
storage.slot1 ??= "dms";
|
||||
storage.slot2 ??= "settings";
|
||||
storage.showDMButton ??= false;
|
||||
storage.showSettingsButton ??= true;
|
||||
|
||||
unpatchAll = applyPatches("YouBar+", logger, {
|
||||
"YouBar buttons": patchYouBarButtons
|
||||
|
|
|
|||
|
|
@ -5,17 +5,7 @@ import { storage } from "@vendetta/plugin";
|
|||
import { getAssetIDByName } from "@vendetta/ui/assets";
|
||||
import { waitFor } from "@shared/lib/waitFor";
|
||||
|
||||
export type YouBarButtonAction = "none" | "dms" | "settings";
|
||||
|
||||
export const YOU_BAR_BUTTON_CHOICES: YouBarButtonAction[] = ["none", "dms", "settings"];
|
||||
|
||||
export const YOU_BAR_BUTTON_LABELS: Record<YouBarButtonAction, string> = {
|
||||
none: "None",
|
||||
dms: "Direct Messages",
|
||||
settings: "Settings"
|
||||
};
|
||||
|
||||
/** Lets the Settings screen force the patched YouBar to re-render right after a slot changes. */
|
||||
/** Lets the Settings screen force the patched YouBar to re-render right after a toggle changes. */
|
||||
export let updateYouBar = () => {};
|
||||
|
||||
/**
|
||||
|
|
@ -48,15 +38,8 @@ function applyButtonPatch(YouBarNotificationsButton: any): () => void {
|
|||
// (see above), not a renamed-API one, so these targets are left exactly as they were.
|
||||
const userSettingsAction = findByProps("openUserSettings");
|
||||
const transitionModule = findByProps("transitionToGuild");
|
||||
const icons: Partial<Record<YouBarButtonAction, number | undefined>> = {
|
||||
dms: getAssetIDByName("ChatIcon"),
|
||||
settings: getAssetIDByName("SettingsIcon")
|
||||
};
|
||||
|
||||
const runAction = (action: YouBarButtonAction) => {
|
||||
if (action === "dms") transitionModule?.transitionToGuild?.("@me");
|
||||
else if (action === "settings") userSettingsAction?.openUserSettings?.();
|
||||
};
|
||||
const ChatIcon = getAssetIDByName("ChatIcon");
|
||||
const SettingsIcon = getAssetIDByName("SettingsIcon");
|
||||
|
||||
return instead("type", YouBarNotificationsButton, (args: any[], OriginalRender: (...a: any[]) => any) => {
|
||||
try {
|
||||
|
|
@ -68,21 +51,24 @@ function applyButtonPatch(YouBarNotificationsButton: any): () => void {
|
|||
|
||||
const IconButton = res.props.children.type;
|
||||
const originalProps = res.props.children.props;
|
||||
// Two independent slots, rendered left to right - each can be off, DMs, or Settings.
|
||||
const slots: YouBarButtonAction[] = [storage.slot1, storage.slot2];
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
{slots.map((action, i) =>
|
||||
action === "none" ? null : (
|
||||
<IconButton
|
||||
key={`you-bar-plus-${i}`}
|
||||
variant={originalProps?.variant || "tertiary"}
|
||||
size={originalProps?.size || "sm"}
|
||||
icon={icons[action]}
|
||||
onPress={() => runAction(action)}
|
||||
/>
|
||||
)
|
||||
{storage.showDMButton && (
|
||||
<IconButton
|
||||
variant={originalProps?.variant || "tertiary"}
|
||||
size={originalProps?.size || "sm"}
|
||||
icon={ChatIcon}
|
||||
onPress={() => transitionModule?.transitionToGuild?.("@me")}
|
||||
/>
|
||||
)}
|
||||
{storage.showSettingsButton && (
|
||||
<IconButton
|
||||
variant={originalProps?.variant || "tertiary"}
|
||||
size={originalProps?.size || "sm"}
|
||||
icon={SettingsIcon}
|
||||
onPress={() => userSettingsAction?.openUserSettings?.()}
|
||||
/>
|
||||
)}
|
||||
{res}
|
||||
</React.Fragment>
|
||||
|
|
|
|||
|
|
@ -4,29 +4,9 @@ import { useProxy } from "@vendetta/storage";
|
|||
import { Forms } from "@vendetta/ui/components";
|
||||
import SettingsScaffold from "@shared/ui/SettingsScaffold";
|
||||
import NoteBox from "@shared/ui/NoteBox";
|
||||
import { updateYouBar, YOU_BAR_BUTTON_CHOICES, YOU_BAR_BUTTON_LABELS, type YouBarButtonAction } from "../patches/youBarButtons";
|
||||
import { updateYouBar } from "../patches/youBarButtons";
|
||||
|
||||
const { FormSection, FormRow } = Forms;
|
||||
|
||||
function nextChoice(current: YouBarButtonAction): YouBarButtonAction {
|
||||
const idx = YOU_BAR_BUTTON_CHOICES.indexOf(current);
|
||||
return YOU_BAR_BUTTON_CHOICES[(idx + 1) % YOU_BAR_BUTTON_CHOICES.length];
|
||||
}
|
||||
|
||||
function SlotRow({ label, slotKey }: { label: string; slotKey: "slot1" | "slot2" }) {
|
||||
const value: YouBarButtonAction = storage[slotKey];
|
||||
|
||||
return (
|
||||
<FormRow
|
||||
label={label}
|
||||
subLabel={YOU_BAR_BUTTON_LABELS[value]}
|
||||
onPress={() => {
|
||||
storage[slotKey] = nextChoice(value);
|
||||
updateYouBar();
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
const { FormSection, FormSwitchRow } = Forms;
|
||||
|
||||
export default function Settings() {
|
||||
useProxy(storage);
|
||||
|
|
@ -37,14 +17,28 @@ export default function Settings() {
|
|||
return (
|
||||
<SettingsScaffold>
|
||||
<NoteBox>
|
||||
YouBar+ adds up to 2 buttons to the YouBar - the row with your avatar and status near the top
|
||||
of the app. Tap a slot below to cycle it through None, Direct Messages, and Settings; the first
|
||||
slot renders on the left. Fork of Purple-EyeZ's YouBar+, ported to Revenge's Vendetta-compat API
|
||||
with a fix for a startup race that could silently skip the button patch for an entire session.
|
||||
Fork of Purple-EyeZ's YouBar+, ported to Revenge's Vendetta-compat API with a fix
|
||||
for a startup race that could silently skip the button patch for an entire session.
|
||||
</NoteBox>
|
||||
<FormSection title="Buttons">
|
||||
<SlotRow label="First button" slotKey="slot1" />
|
||||
<SlotRow label="Second button" slotKey="slot2" />
|
||||
<FormSwitchRow
|
||||
label="Direct Messages button"
|
||||
subLabel="Show the DM button in the YouBar"
|
||||
value={!!storage.showDMButton}
|
||||
onValueChange={(v: boolean) => {
|
||||
storage.showDMButton = v;
|
||||
updateYouBar();
|
||||
}}
|
||||
/>
|
||||
<FormSwitchRow
|
||||
label="Settings button"
|
||||
subLabel="Show the Settings button in the YouBar"
|
||||
value={!!storage.showSettingsButton}
|
||||
onValueChange={(v: boolean) => {
|
||||
storage.showSettingsButton = v;
|
||||
updateYouBar();
|
||||
}}
|
||||
/>
|
||||
</FormSection>
|
||||
</SettingsScaffold>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -263,17 +263,15 @@
|
|||
"category": "Moderation & Appearance",
|
||||
"status": "revived",
|
||||
"accent": "#5865F2",
|
||||
"tagline": "Configurable buttons on the YouBar - up to 2 at a time, in your chosen order.",
|
||||
"note": "Fork of Purple-EyeZ's YouBar+. Fixed a startup race condition: the original did a single one-shot component lookup during onLoad and silently gave up for the rest of the session if it ran before the target had registered in Metro yet (a real risk on a cold app start) - restarting Discord just got lucky on a re-roll. This port polls for the component instead of looking it up once. Also replaced the original's two independent on/off toggles with a real slot-based system: 2 ordered slots, each set to None, Direct Messages, or Settings.",
|
||||
"howItWorks": "The YouBar is the row near your avatar/status at the top of the app. This plugin patches its notification button area to also render up to 2 extra icon buttons, each pulled from one of 2 configurable slots. Each slot cycles between None, Direct Messages (jumps to your DMs), and Settings (opens user settings) - tap a slot in the plugin's settings to cycle it. Slot order controls left-to-right button order, and each slot is independent, so you can run just one button, both, or neither. Both slots default to Direct Messages then Settings, matching the original plugin's default look.",
|
||||
"tagline": "Adds DM and/or Settings buttons to the YouBar.",
|
||||
"note": "Fork of Purple-EyeZ's YouBar+. Fixed a startup race condition where the button patch could silently never apply for an entire session - the original did a single one-shot lookup for YouBarNotificationsButton at onLoad and gave up permanently if it wasn't registered in Metro yet, which restarting Discord only fixed by luck. Now retries until the component shows up.",
|
||||
"howItWorks": "The YouBar is the row near your avatar/status at the top of the app. This plugin patches its notification button area to also render a DM button and/or a Settings button, each independently toggleable. DM jumps straight to your DMs; Settings opens user settings.",
|
||||
"features": [
|
||||
"Up to 2 buttons on the YouBar, each independently configurable",
|
||||
"Choices per slot: None, Direct Messages, Settings",
|
||||
"Slot order controls left-to-right button order",
|
||||
"Independent toggles for the DM and Settings buttons",
|
||||
"Settings changes apply immediately, no restart needed",
|
||||
"Startup race condition fixed - polls for the target component instead of a single one-shot lookup"
|
||||
],
|
||||
"commands": [],
|
||||
"limitations": "Only wires up to actions with a confirmed, still-working lookup (jump to DMs, open Settings) - no additional slot choices were added beyond what could be verified against a real findByProps target."
|
||||
"limitations": "Depends on YouBarNotificationsButton keeping a similar render shape - guarded so a mismatch just means no extra buttons, not a crash."
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue