Skip to content

Commit 8ba52bd

Browse files
committed
🐛 コンテンツウィンドウを閉じたときにdrpcが残り続けるのを修正
1 parent cb2fa5f commit 8ba52bd

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/@types/plugin.d.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ Mirakurun: Apache License
255255
/// <reference types="react" />
256256
/// <reference types="scheduler" />
257257

258-
import { useToast } from "react-toastify"
259258
import * as Recoil from "recoil"
260259

261260
type GlobalEvent = Event & {
@@ -38495,6 +38494,9 @@ export declare type CustomComponent = {
3849538494
id: string
3849638495
component: React.VFC<{}>
3849738496
}
38497+
export declare type OnBackgroundComponent = {
38498+
position: "onBackground"
38499+
} & CustomComponent
3849838500
export declare type OnSplashComponent = {
3849938501
position: "onSplash"
3850038502
} & CustomComponent
@@ -38512,6 +38514,7 @@ export declare type OnForwardComponent = {
3851238514
position: "onForward"
3851338515
} & CustomComponent
3851438516
export declare type ComponentWithPosition =
38517+
| OnBackgroundComponent
3851538518
| OnSplashComponent
3851638519
| OnSettingComponent
3851738520
| OnPlayerComponent
@@ -38530,9 +38533,7 @@ export declare type PluginInRendererArgs = {
3853038533
functions: {
3853138534
openWindow: (args: OpenWindowArg) => Promise<number>
3853238535
}
38533-
hooks: {
38534-
useToast: typeof useToast
38535-
}
38536+
hooks: {}
3853638537
atoms: {
3853738538
globalContentPlayerIdsSelector: Recoil.RecoilValueReadOnly<number[]>
3853838539
globalContentPlayerPlayingContentFamily: (

src/miraktest-drpc/index.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ const main: InitPlugin = {
7777
},
7878
components: [
7979
{
80-
id: `${prefix}.player`,
81-
position: "onPlayer",
80+
id: `${prefix}.background`,
81+
position: "onBackground",
8282
label: meta.name,
8383
component: () => {
8484
const activeWindowId = useRecoilValue(
@@ -94,13 +94,18 @@ const main: InitPlugin = {
9494
const isPlaying = useRecoilValue(atoms.contentPlayerIsPlayingAtom)
9595
const isEnabled = useRecoilValue(isEnabledAtom)
9696
useEffect(() => {
97-
if (!isEnabled || !isPlaying) {
97+
if (
98+
!isEnabled ||
99+
activeWindowId === null ||
100+
(!isPlaying && remoteWindow.id === activeWindowId)
101+
) {
98102
packages.IpcRenderer.invoke(activityEventId, null)
99103
return
100104
}
101105
if (
102106
remoteWindow.id !== activeWindowId ||
103-
!playingContent?.service
107+
!playingContent?.service ||
108+
!isPlaying
104109
) {
105110
return
106111
}

0 commit comments

Comments
 (0)