Skip to content

Commit

Permalink
Merge pull request #10811 from DestinyItemManager/reverse-it
Browse files Browse the repository at this point in the history
Correctly reverse failed save search / revamp dim-api tests
  • Loading branch information
bhollis authored Nov 27, 2024
2 parents a19bffd + 24c87bb commit ef6149d
Show file tree
Hide file tree
Showing 3 changed files with 695 additions and 628 deletions.
15 changes: 14 additions & 1 deletion src/app/dim-api/api-types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import {
DeleteLoadoutUpdate,
DeleteSearchUpdate,
DestinyVersion,
Loadout,
ProfileUpdate,
SearchType,
} from '@destinyitemmanager/dim-api-types';

// https://stackoverflow.com/questions/51691235/typescript-map-union-type-to-another-union-type
type AddUpdateInfo<U> = U extends ProfileUpdate
? U & {
/** The state before this update - if it fails we can use this to roll back */
before?: U['payload'];
before: U['payload'] | undefined;
/** The account (if any) this update refers to */
platformMembershipId?: string;
destinyVersion?: DestinyVersion;
Expand All @@ -22,9 +24,20 @@ export interface DeleteLoadoutUpdateWithRollback extends DeleteLoadoutUpdate {
destinyVersion: DestinyVersion;
}

export interface DeleteSearchUpdateWithRollback extends DeleteSearchUpdate {
before: {
query: string;
type: SearchType;
saved: boolean;
};
platformMembershipId: string;
destinyVersion: DestinyVersion;
}

/**
* A version of ProfileUpdate that also includes rollback info in a "before" property.
*/
export type ProfileUpdateWithRollback =
| DeleteSearchUpdateWithRollback
| DeleteLoadoutUpdateWithRollback
| AddUpdateInfo<ProfileUpdate>;
Loading

0 comments on commit ef6149d

Please sign in to comment.