Merge pull request #180 from LCE-Hub/main

merge main into diamond
This commit is contained in:
/home/neo 2026-08-11 13:32:09 +03:00 committed by GitHub
commit b0da976374
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 4 deletions

View file

@ -1,4 +1,5 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useConfig } from "../../context/LauncherContext";
const SGA_CHARS = "abcdefghijklmnopqrstuvwxyz".split(""); const SGA_CHARS = "abcdefghijklmnopqrstuvwxyz".split("");
@ -15,7 +16,11 @@ interface Particle {
export const ClickParticles: React.FC = React.memo(() => { export const ClickParticles: React.FC = React.memo(() => {
const [bursts, setBursts] = useState<Particle[]>([]); const [bursts, setBursts] = useState<Particle[]>([]);
const { animationsEnabled } = useConfig();
useEffect(() => { useEffect(() => {
if (!animationsEnabled) return;
const handlePressSound = (e: MouseEvent) => { const handlePressSound = (e: MouseEvent) => {
const newParticles: Particle[] = []; const newParticles: Particle[] = [];
const particleCount = 8; const particleCount = 8;
@ -40,8 +45,14 @@ export const ClickParticles: React.FC = React.memo(() => {
window.addEventListener("mousedown", handlePressSound); window.addEventListener("mousedown", handlePressSound);
return () => window.removeEventListener("mousedown", handlePressSound); return () => window.removeEventListener("mousedown", handlePressSound);
}, []); }, [animationsEnabled]);
useEffect(() => {
if (!animationsEnabled) {
setBursts([]);
}
}, [animationsEnabled])
return ( return (
<div className="fixed inset-0 pointer-events-none z-[9999] overflow-hidden"> <div className="fixed inset-0 pointer-events-none z-[9999] overflow-hidden">
{bursts.map((p) => ( {bursts.map((p) => (

View file

@ -7,6 +7,7 @@ import { useSkinSync } from "../hooks/useSkinSync";
import { useDiscordRPC } from "../hooks/useDiscordRPC"; import { useDiscordRPC } from "../hooks/useDiscordRPC";
import { useGamepad } from "../hooks/useGamepad"; import { useGamepad } from "../hooks/useGamepad";
import { useUpdateCheck } from "../hooks/useUpdateCheck"; import { useUpdateCheck } from "../hooks/useUpdateCheck";
import RpcService from "../services/RpcService";
interface UIContextType { interface UIContextType {
activeView: string; activeView: string;
@ -161,8 +162,11 @@ export function LauncherProvider({ children }: { children: React.ReactNode }) {
const setupVisibilityDetection = async () => { const setupVisibilityDetection = async () => {
try { try {
const { listen } = await import("@tauri-apps/api/event"); const { listen } = await import("@tauri-apps/api/event");
const unlistenClose = await listen("tauri://close-requested", () => { const unlistenClose = await listen("tauri://close-requested", async () => {
setIsWindowVisible(false); setIsWindowVisible(false);
if (config.rpcEnabled) {
await RpcService.StopRPC();
}
}); });
const unlistenShow = await listen("tauri://window-shown", () => { const unlistenShow = await listen("tauri://window-shown", () => {
@ -190,7 +194,7 @@ export function LauncherProvider({ children }: { children: React.ReactNode }) {
}; };
setupVisibilityDetection(); setupVisibilityDetection();
}, []); }, [config.rpcEnabled]);
const uiValue = useMemo(() => ({ const uiValue = useMemo(() => ({
activeView, setActiveView, showIntro, setShowIntro, activeView, setActiveView, showIntro, setShowIntro,

View file

@ -1,4 +1,4 @@
import { setActivity, start } from "tauri-plugin-drpc"; import { setActivity, start, clearActivity, stop } from "tauri-plugin-drpc";
import { import {
Activity, Activity,
ActivityType, ActivityType,
@ -72,6 +72,19 @@ class RPC {
console.error("Failed to set RPC activity:", e); console.error("Failed to set RPC activity:", e);
} }
} }
public async StopRPC() {
try {
await clearActivity();
await stop();
} catch (e) {
// no need to handle errors here as the launcher will close anyways!
} finally {
this.initialized = false;
this.initializationPromise = null;
sessionStorage.removeItem("lce_rpc_started");
}
}
} }
export default new RPC(); export default new RPC();