Skip to content

Commit

Permalink
feat: add show timestamps settings
Browse files Browse the repository at this point in the history
  • Loading branch information
skullysmods committed Oct 25, 2024
1 parent 5f7c50a commit 45d9466
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
6 changes: 6 additions & 0 deletions websites/A/Anime Sama/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
"icon": "fad fa-user-secret",
"value": false
},
{
"id": "timestamps",
"title": "Show Timestamps",
"icon": "fad fa-stopwatch",
"value": true
},
{
"id": "cover",
"title": "Show Cover",
Expand Down
7 changes: 6 additions & 1 deletion websites/A/Anime Sama/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ presence.on("UpdateData", async () => {
},
{ pathname, href } = document.location,
pathArr = pathname.split("/"),
[showButtons, privacyMode, showCover] = await Promise.all([
[showButtons, privacyMode, showTimestamps, showCover] = await Promise.all([
presence.getSetting<boolean>("buttons"),
presence.getSetting<boolean>("privacy"),
presence.getSetting<boolean>("timestamps"),
presence.getSetting<boolean>("cover"),
]);

Expand Down Expand Up @@ -125,6 +126,10 @@ presence.on("UpdateData", async () => {
}

if (!showButtons || privacyMode) delete presenceData.buttons;
if (!showTimestamps) {
delete presenceData.startTimestamp;
delete presenceData.endTimestamp;
}
if (!showCover || privacyMode) presenceData.largeImageKey = Assets.Logo;
if (presenceData.details) presence.setActivity(presenceData);
else presence.setActivity();
Expand Down
6 changes: 6 additions & 0 deletions websites/V/Voiranime/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
"icon": "fad fa-user-secret",
"value": false
},
{
"id": "timestamps",
"title": "Show Timestamps",
"icon": "fad fa-stopwatch",
"value": true
},
{
"id": "buttons",
"title": "Show Buttons",
Expand Down
17 changes: 12 additions & 5 deletions websites/V/Voiranime/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ presence.on(
);

presence.on("UpdateData", async () => {
const [newLang, privacyMode, showButtons] = await Promise.all([
presence.getSetting<string>("lang").catch(() => "en"),
presence.getSetting<boolean>("privacy"),
presence.getSetting<boolean>("buttons"),
]);
const [newLang, privacyMode, showTimestamps, showButtons] = await Promise.all(
[
presence.getSetting<string>("lang").catch(() => "en"),
presence.getSetting<boolean>("privacy"),
presence.getSetting<boolean>("timestamps"),
presence.getSetting<boolean>("buttons"),
]
);

if (currentLang !== newLang || !strings) {
currentLang = newLang;
Expand Down Expand Up @@ -154,6 +157,10 @@ presence.on("UpdateData", async () => {
}

if (!showButtons || privacyMode) delete presenceData.buttons;
if (!showTimestamps) {
delete presenceData.startTimestamp;
delete presenceData.endTimestamp;
}
if (presenceData.details) presence.setActivity(presenceData);
else presence.setActivity();
});

0 comments on commit 45d9466

Please sign in to comment.