fix(CommandPalette.vue): ensure peers and contacts are arrays before processing to prevent errors
This commit is contained in:
@@ -210,29 +210,33 @@ export default {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// add peers
|
// add peers
|
||||||
for (const peer of this.peers) {
|
if (Array.isArray(this.peers)) {
|
||||||
results.push({
|
for (const peer of this.peers) {
|
||||||
id: `peer-${peer.destination_hash}`,
|
results.push({
|
||||||
title: peer.custom_display_name ?? peer.display_name,
|
id: `peer-${peer.destination_hash}`,
|
||||||
description: peer.destination_hash,
|
title: peer.custom_display_name ?? peer.display_name,
|
||||||
icon: peer.lxmf_user_icon?.icon_name ?? "account",
|
description: peer.destination_hash,
|
||||||
iconForeground: peer.lxmf_user_icon?.foreground_colour,
|
icon: peer.lxmf_user_icon?.icon_name ?? "account",
|
||||||
iconBackground: peer.lxmf_user_icon?.background_colour,
|
iconForeground: peer.lxmf_user_icon?.foreground_colour,
|
||||||
type: "peer",
|
iconBackground: peer.lxmf_user_icon?.background_colour,
|
||||||
peer: peer,
|
type: "peer",
|
||||||
});
|
peer: peer,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add contacts
|
// add contacts
|
||||||
for (const contact of this.contacts) {
|
if (Array.isArray(this.contacts)) {
|
||||||
results.push({
|
for (const contact of this.contacts) {
|
||||||
id: `contact-${contact.id}`,
|
results.push({
|
||||||
title: contact.name,
|
id: `contact-${contact.id}`,
|
||||||
description: this.$t("app.call") + ` ${contact.remote_identity_hash}`,
|
title: contact.name,
|
||||||
icon: "phone",
|
description: this.$t("app.call") + ` ${contact.remote_identity_hash}`,
|
||||||
type: "contact",
|
icon: "phone",
|
||||||
contact: contact,
|
type: "contact",
|
||||||
});
|
contact: contact,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
@@ -313,7 +317,7 @@ export default {
|
|||||||
|
|
||||||
// fetch telephone contacts
|
// fetch telephone contacts
|
||||||
const contactResponse = await window.axios.get("/api/v1/telephone/contacts");
|
const contactResponse = await window.axios.get("/api/v1/telephone/contacts");
|
||||||
this.contacts = contactResponse.data;
|
this.contacts = Array.isArray(contactResponse.data) ? contactResponse.data : [];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to load command palette data:", e);
|
console.error("Failed to load command palette data:", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user