mirror of
https://github.com/stashapp/CommunityScripts.git
synced 2026-02-04 20:04:27 -06:00
[discordPresence] Throttle presence updates (#365)
This commit is contained in:
parent
bd566a03fd
commit
d6e7243c33
@ -85,6 +85,7 @@
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
const player = () => document.querySelector("#VideoJsPlayer video");
|
||||
|
||||
let WAITING_FOR_REFRESH = true;
|
||||
let SCENE_ID = null;
|
||||
/** @type {FlattenedSceneData?} */ let cachedSceneData;
|
||||
|
||||
@ -201,7 +202,16 @@
|
||||
);
|
||||
}
|
||||
|
||||
async function setDiscordActivity() {
|
||||
async function setDiscordActivity(event) {
|
||||
if (event?.type === "timeupdate") {
|
||||
if (!WAITING_FOR_REFRESH) {
|
||||
return;
|
||||
}
|
||||
|
||||
WAITING_FOR_REFRESH = false;
|
||||
setTimeout(() => (WAITING_FOR_REFRESH = true), 5000);
|
||||
}
|
||||
|
||||
const sceneData = await getSceneData(SCENE_ID);
|
||||
if (!sceneData) return;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ name: Discord Presence
|
||||
description: Sets currently playing scene data as your Discord status. See README for prerequisites and config options (blue hyperlink next to enable/disable button)
|
||||
url: https://github.com/stashapp/CommunityScripts/tree/main/plugins/discordPresence
|
||||
# requires: CommunityScriptsUILibrary
|
||||
version: 1.1
|
||||
version: 1.2
|
||||
settings:
|
||||
discordClientId:
|
||||
displayName: Custom Discord application ID
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user