fix: UI bug when renaming records

This commit is contained in:
Luka Dekanozishvili 2026-02-03 17:49:26 +01:00
parent 79e10d1759
commit 9523848bb6

View file

@ -153,10 +153,17 @@ export function isRecordValid(
return '';
}
// Makes sure to update/replace records which have been implicitly updated by either a TTL change or have been created
// Find all records with the same name and type, delete them, insert the records from the API response
export function handleUiRecordUpdates(oldRecords: DnsRecord[], data: any): DnsRecord[] {
let records = oldRecords.filter((rec) => rec.record_type !== data.type || rec.name !== data.name);
const updatedIds = new Set(data.records.map((r: any) => r.id));
// Remove stale records with the same ID
let records = oldRecords.filter(
rec => !updatedIds.has(rec.id)
);
for (let rec of data.records) {
let newRecord: DnsRecord = {
id: rec.id,