mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-20 15:18:50 -05:00
Requests + Size GlobalBadges margin properly
This commit is contained in:
parent
f91c4977a2
commit
8f629c3d4f
4 changed files with 124 additions and 6 deletions
84
src/equicordplugins/customIdle/index.ts
Normal file
84
src/equicordplugins/customIdle/index.ts
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { Notices } from "@api/index";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { makeRange } from "@components/PluginSettings/components";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { FluxDispatcher } from "@webpack/common";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
idleTimeout: {
|
||||
description: "Minutes before Discord goes idle (0 to disable auto-idle)",
|
||||
type: OptionType.SLIDER,
|
||||
markers: makeRange(0, 60, 5),
|
||||
default: 10,
|
||||
stickToMarkers: false
|
||||
},
|
||||
remainInIdle: {
|
||||
description: "When you come back to Discord, remain idle until you confirm you want to go online",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true
|
||||
}
|
||||
});
|
||||
|
||||
let sentNotif = false;
|
||||
export default definePlugin({
|
||||
name: "CustomIdle",
|
||||
description: "Allows you to set the time before Discord goes idle (or disable auto-idle)",
|
||||
authors: [Devs.newwares],
|
||||
settings,
|
||||
patches: [
|
||||
{
|
||||
find: "IDLE_DURATION:function(){return",
|
||||
replacement: {
|
||||
match: /(IDLE_DURATION:function\(\){return )\i/,
|
||||
replace: "$1$self.getIdleTimeout()"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: "type:\"IDLE\",idle:",
|
||||
replacement: [
|
||||
{
|
||||
match: /Math\.min\((\i\.AfkTimeout\.getSetting\(\)\*\i\.default\.Millis\.SECOND),\i\.IDLE_DURATION\)/,
|
||||
replace: "$1" // decouple idle from afk (phone notifs will remain at 10 mins)
|
||||
},
|
||||
{
|
||||
match: /\i\.default\.dispatch\({type:"IDLE",idle:!1}\)/,
|
||||
replace: "$self.handleOnline()"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
handleOnline() { // might be called in quick succession
|
||||
if (!settings.store.remainInIdle) {
|
||||
FluxDispatcher.dispatch({
|
||||
type: "IDLE",
|
||||
idle: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!sentNotif) {
|
||||
sentNotif = true;
|
||||
Notices.showNotice("Welcome back! Click the button to go online. Click the X to stay idle until reload.", "Exit idle", () => {
|
||||
Notices.popNotice();
|
||||
FluxDispatcher.dispatch({
|
||||
type: "IDLE",
|
||||
idle: false
|
||||
});
|
||||
sentNotif = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
getIdleTimeout() { // milliseconds, default is 6e5
|
||||
const { idleTimeout } = settings.store;
|
||||
return idleTimeout === 0 ? Number.MAX_SAFE_INTEGER : idleTimeout * 60000;
|
||||
},
|
||||
start() {
|
||||
sentNotif = false;
|
||||
}
|
||||
});
|
39
src/equicordplugins/dndWhilePlaying/index.ts
Normal file
39
src/equicordplugins/dndWhilePlaying/index.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByCodeLazy } from "@webpack";
|
||||
import { FluxDispatcher, PresenceStore, UserStore } from "@webpack/common";
|
||||
|
||||
const updateAsync = findByCodeLazy("updateAsync");
|
||||
|
||||
async function runningGamesChange(event) {
|
||||
const { games } = event;
|
||||
let status;
|
||||
let savedStatus;
|
||||
if (games.length > 0) {
|
||||
const currentUser = UserStore.getCurrentUser();
|
||||
status = PresenceStore.getStatus(currentUser.id);
|
||||
savedStatus = status;
|
||||
if (status === "invisible") return;
|
||||
if (status !== "dnd") updateAsync("dnd");
|
||||
} else if (games.length === 0) {
|
||||
updateAsync(savedStatus);
|
||||
}
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "DNDWhilePlaying",
|
||||
description: "Automatically updates your status to Do Not Disturb when playing games and resets it back when stopped playing",
|
||||
authors: [EquicordDevs.thororen],
|
||||
start() {
|
||||
FluxDispatcher.subscribe("RUNNING_GAMES_CHANGE", runningGamesChange);
|
||||
},
|
||||
stop() {
|
||||
FluxDispatcher.unsubscribe("RUNNING_GAMES_CHANGE", runningGamesChange);
|
||||
}
|
||||
});
|
|
@ -1,3 +0,0 @@
|
|||
[class*="profileBadges"] {
|
||||
flex: none;
|
||||
}
|
|
@ -16,8 +16,6 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import "./fixBadgeOverflow.css";
|
||||
|
||||
import { addBadge, BadgePosition, ProfileBadge, removeBadge } from "@api/Badges";
|
||||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
@ -62,7 +60,7 @@ const BadgeComponent = ({ name, img }: { name: string, img: string; }) => {
|
|||
<img
|
||||
{...tooltipProps}
|
||||
src={img}
|
||||
style={{ width: "22px", height: "22px", transform: name.includes("Replugged") ? "scale(0.9)" : null, margin: "0 2px" }}
|
||||
style={{ width: "22px", height: "22px", transform: name.includes("Replugged") ? null : "scale(0.9)", margin: "0 1px" }}
|
||||
/>
|
||||
)}
|
||||
</Tooltip>
|
||||
|
|
Loading…
Add table
Reference in a new issue