Evita múltiplos acessos remotos por provider ao reaproveitar entrada existente
This commit is contained in:
parent
81d1a7c7f7
commit
b663268791
1 changed files with 8 additions and 1 deletions
|
|
@ -2731,12 +2731,19 @@ export const upsertRemoteAccessViaToken = mutation({
|
|||
const cleanedNotes = args.notes?.trim() ? args.notes.trim() : null
|
||||
const timestamp = Date.now()
|
||||
const existingEntries = normalizeRemoteAccessList(machine.remoteAccess)
|
||||
const existingIndex = existingEntries.findIndex(
|
||||
let existingIndex = existingEntries.findIndex(
|
||||
(entry) =>
|
||||
entry.provider.toLowerCase() === trimmedProvider.toLowerCase() &&
|
||||
entry.identifier.toLowerCase() === trimmedIdentifier.toLowerCase()
|
||||
)
|
||||
|
||||
// Se o identificador mudar (ex.: RustDesk gerando novo ID), reaproveitamos a entrada do mesmo provider
|
||||
if (existingIndex < 0) {
|
||||
existingIndex = existingEntries.findIndex(
|
||||
(entry) => entry.provider.toLowerCase() === trimmedProvider.toLowerCase()
|
||||
)
|
||||
}
|
||||
|
||||
const entryId = existingIndex >= 0 ? existingEntries[existingIndex].id : createRemoteAccessId()
|
||||
const updatedEntry: RemoteAccessEntry = {
|
||||
id: entryId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue