File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { UserProfile as UserProfileType } from "@monkeytype/schemas/users" ;
21import { JSXElement , Show } from "solid-js" ;
32
43import { getActivePage } from "../../../states/core" ;
@@ -9,7 +8,7 @@ export function MyProfile(): JSXElement {
98 const profile = ( ) =>
109 getActivePage ( ) === "account" ? getSnapshot ( ) : undefined ;
1110 return (
12- < Show when = { profile ( ) as UserProfileType } fallback = "no user found" >
11+ < Show when = { profile ( ) } fallback = "no user found" >
1312 { ( p ) => < UserProfile profile = { p ( ) } isAccountPage /> }
1413 </ Show >
1514 ) ;
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ export type Snapshot = Omit<
7171 xp : number ;
7272 testActivity ?: ModifiableTestActivityCalendar ;
7373 testActivityByYear ?: { [ key : string ] : TestActivityCalendar } ;
74+ isMiniSnapshot ?: never ;
7475} ;
7576
7677const defaultSnap = {
Original file line number Diff line number Diff line change @@ -5,23 +5,30 @@ import { Mode } from "@monkeytype/schemas/shared";
55
66export type MiniSnapshot = Omit <
77 Snapshot ,
8- "results " | "presets " | "filterPresets "
9- > ;
8+ "testActivity " | "testActivityByYear " | "isMiniSnapshot "
9+ > & { isMiniSnapshot : boolean } ;
1010const [ snapshot , updateSnapshot ] = createStore < {
1111 value : MiniSnapshot | undefined ;
1212} > ( { value : undefined } ) ;
1313
1414/**
1515 * This does not update the DB.snapshot. Use DB.setSnapshot for now.
1616 */
17- export function _setSnapshot ( newValue : MiniSnapshot | undefined ) : void {
17+ export function _setSnapshot ( newValue : Snapshot | undefined ) : void {
1818 if ( newValue === undefined ) {
1919 updateSnapshot ( "value" , undefined ) ;
2020 } else {
21- updateSnapshot (
22- "value" ,
23- reconcile ( structuredClone ( unwrap ( newValue ) ) , { merge : true } ) ,
24- ) ;
21+ const snapshot = structuredClone ( unwrap ( newValue ) ) ;
22+
23+ delete snapshot . testActivity ;
24+ delete snapshot . testActivityByYear ;
25+
26+ const miniSnapshot = {
27+ ...snapshot ,
28+ isMiniSnapshot : true ,
29+ } ;
30+
31+ updateSnapshot ( "value" , reconcile ( miniSnapshot , { merge : true } ) ) ;
2532 }
2633}
2734
You can’t perform that action at this time.
0 commit comments