mirror of
https://github.com/YuzuZensai/Discord-Presence-Relay.git
synced 2026-09-13 17:01:36 +00:00
✨ feat: locking existing primary
This commit is contained in:
@@ -525,6 +525,17 @@ export class RpcRelay extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (changed) this.emitStatus()
|
if (changed) this.emitStatus()
|
||||||
|
|
||||||
|
if (this.lockedPrimary !== null) {
|
||||||
|
const lockedSlot = this.claimed.findIndex(
|
||||||
|
(c) => platform.getInstanceProcess(c.index)?.executable === this.lockedPrimary
|
||||||
|
)
|
||||||
|
if (lockedSlot > 0) {
|
||||||
|
this.discovering = false
|
||||||
|
await this.reorderForPrimary()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.lastError = err instanceof Error ? err.message : String(err)
|
this.lastError = err instanceof Error ? err.message : String(err)
|
||||||
this.emitStatus()
|
this.emitStatus()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ArrowUpToLine, Info, Lock } from 'lucide-react'
|
import { ArrowUpToLine, Lock, LockOpen } from 'lucide-react'
|
||||||
import type { RelayInstance } from '../../../main/relay'
|
import type { RelayInstance } from '../../../main/relay'
|
||||||
import { Toggle } from './Toggle'
|
import { Toggle } from './Toggle'
|
||||||
import { Button } from './Button'
|
import { Button } from './Button'
|
||||||
@@ -57,6 +57,23 @@ export function InstanceRow({
|
|||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const lockButton = (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
className="p-1 shrink-0"
|
||||||
|
disabled={!canPromote || reordering}
|
||||||
|
onClick={() => onPromote(instance.index)}
|
||||||
|
aria-label="Lock as primary"
|
||||||
|
title={
|
||||||
|
!canPromote
|
||||||
|
? 'Cannot resolve this Discord’s executable path'
|
||||||
|
: 'Lock this Discord as primary so it stays first even after restarts.'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<LockOpen className="w-4 h-4 text-zinc-400 hover:text-zinc-100 transition-colors" />
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
|
||||||
const info = (
|
const info = (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@@ -81,17 +98,7 @@ export function InstanceRow({
|
|||||||
<div className="flex items-center justify-between gap-2">
|
<div className="flex items-center justify-between gap-2">
|
||||||
{info}
|
{info}
|
||||||
<div className="flex items-center gap-1 shrink-0">
|
<div className="flex items-center gap-1 shrink-0">
|
||||||
{instance.locked ? (
|
{instance.locked ? unlockButton : lockButton}
|
||||||
unlockButton
|
|
||||||
) : (
|
|
||||||
<Info className="w-4 h-4 text-zinc-400 hover:text-zinc-100 cursor-help transition-colors">
|
|
||||||
<title>
|
|
||||||
The primary instance gets full passthrough and can't be turned off. It's
|
|
||||||
the Discord that started first (discord-ipc-0). Use Promote on another instance to
|
|
||||||
make it primary instead.
|
|
||||||
</title>
|
|
||||||
</Info>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -101,7 +108,6 @@ export function InstanceRow({
|
|||||||
<div className="flex items-center justify-between gap-2">
|
<div className="flex items-center justify-between gap-2">
|
||||||
{info}
|
{info}
|
||||||
<div className="flex items-center gap-1 shrink-0">
|
<div className="flex items-center gap-1 shrink-0">
|
||||||
{instance.locked && unlockButton}
|
|
||||||
{promoteButton}
|
{promoteButton}
|
||||||
<Toggle
|
<Toggle
|
||||||
checked={instance.enabled}
|
checked={instance.enabled}
|
||||||
|
|||||||
Reference in New Issue
Block a user