fix: UI bug when renaming records
This commit is contained in:
parent
79e10d1759
commit
9523848bb6
1 changed files with 8 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue