Refactor: eliminate "special" entity type and use DID-based logic

Replace string-based entity type matching with DID-based logic for "You" and "Unnamed" entities. Treat these as regular person entities instead of special types.

- Remove "special" type from EntitySelectionEvent interface
- Update EntityGrid to emit "You" and "Unnamed" as person entities
- Simplify SpecialEntityCard emit structure (remove entityType parameter)
- Refactor GiftedDialog to process all person entities with DID-based logic
- Update ContactGiftingView and HomeView to use DID-based entity creation
- Remove string literals "You" and "Unnamed" from method signatures
This commit is contained in:
Jose Olarte III
2025-08-15 13:22:49 +08:00
parent 6acebb66ef
commit a4528c5703
6 changed files with 85 additions and 94 deletions

View File

@@ -28,7 +28,7 @@
<button
type="button"
class="block w-full text-center text-sm uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-3 py-1.5 rounded-md"
@click="openDialog('You')"
@click="openDialog({ did: activeDid, name: 'You' })"
>
<font-awesome icon="gift" class="fa-fw"></font-awesome>
</button>
@@ -48,7 +48,7 @@
<button
type="button"
class="block w-full text-center text-sm uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-3 py-1.5 rounded-md"
@click="openDialog('Unnamed')"
@click="openDialog({ did: '', name: 'Unnamed' })"
>
<font-awesome icon="gift" class="fa-fw"></font-awesome>
</button>
@@ -207,7 +207,7 @@ export default class ContactGiftingView extends Vue {
}
}
openDialog(contact?: GiverReceiverInputInfo | "Unnamed" | "You") {
openDialog(contact?: GiverReceiverInputInfo) {
// Determine the selected entity based on contact type
const selectedEntity = this.createEntityFromContact(contact);
@@ -231,19 +231,26 @@ export default class ContactGiftingView extends Vue {
/**
* Creates an entity object from the contact parameter
* Uses DID-based logic to determine "You" and "Unnamed" entities
*/
private createEntityFromContact(
contact?: GiverReceiverInputInfo | "Unnamed" | "You",
contact?: GiverReceiverInputInfo,
): GiverReceiverInputInfo | undefined {
if (contact === "You") {
if (!contact) {
return undefined;
}
// Handle GiverReceiverInputInfo object
if (contact.did === this.activeDid) {
// If DID matches active DID, create "You" entity
return { did: this.activeDid, name: "You" };
} else if (contact === "Unnamed") {
} else if (!contact.did || contact.did === "") {
// If DID is empty/null, create "Unnamed" entity
return { did: "", name: "Unnamed" };
} else if (contact) {
} else {
// Create a copy of the contact to avoid modifying the original
return { ...contact };
}
return undefined;
}
/**