Skip to content

Commit

Permalink
fix activity not triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
SuspiciousLookingOwl committed Jul 18, 2024
1 parent 1584ff0 commit 9fdf4fd
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/libs/discord/hooks/rich-presence.hook.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TimeUtil, UrlUtil } from "@common";
import type { QueueContextStore } from "@queue";
import { createEffect, createSignal, onMount, type Accessor } from "solid-js";
import { createEffect, createSignal, type Accessor } from "solid-js";
import { RichPresenceUtil } from "../utils";

export type IRichPresence = {
Expand Down Expand Up @@ -54,15 +54,8 @@ export const useRichPresence = (params: Params) => {
const [activity, setActivity] = createSignal<IRichPresence | null>(null);
let currentActivity = "";

onMount(() => updateListeningActivity());

createEffect(() => {
if (params.enabled()) updateListeningActivity();
else setActivity(null);
});

const updateListeningActivity = async () => {
if (!params.enabled) return setActivity(null);
if (!params.enabled()) return setActivity(null);

const nowPlaying = params.queueContext.data.nowPlaying;
const voiceChannel = params.queueContext.data.voiceChannel;
Expand Down Expand Up @@ -116,10 +109,10 @@ export const useRichPresence = (params: Params) => {
}

// TODO better way to check current activity
if (activity() && (!data || currentActivity === JSON.stringify(data))) return;
if (!data || currentActivity === JSON.stringify(data)) return;
currentActivity = JSON.stringify(data);
setActivity(RichPresenceUtil.toPresence(data));
};
});

return activity;
};

0 comments on commit 9fdf4fd

Please sign in to comment.