Refactor base types for entities and tombstones
Rename the base Entity type to ApiEntity, and the base EntityToombstone to ApiTombstone to better reflect the reality that its only used in the API interface and that the client and server types uses its own base if any. Remove EntityLiving and pull EntityTombstone out of of the base entity type so that the types based on ApiEntity are always living entities and if it's possible for it to contain tombstone this will be explicitly told with the type including a union with ApiTombstone. Refactor the types of the ClientEntity and ClientMap to better reflect the types of the entities it stores and converts to/from.
This commit is contained in:
parent
e3ff872b5c
commit
985b8e0950
13 changed files with 107 additions and 102 deletions
|
@ -1,6 +1,6 @@
|
|||
import type { Entity } from "~/shared/types/common";
|
||||
import type { ApiEntity, ApiTombstone } from "~/shared/types/api";
|
||||
|
||||
export function applyUpdatesToArray<T extends Entity>(updates: T[], entities: T[]) {
|
||||
export function applyUpdatesToArray<T extends ApiEntity | ApiTombstone>(updates: T[], entities: T[]) {
|
||||
const idMap = new Map(entities.map((e, i) => [e.id, i]));
|
||||
for (const update of updates) {
|
||||
const index = idMap.get(update.id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue