Skip to content

Commit a1a9b21

Browse files
authored
Fix some glaring performance issues in history view as we prepare to release it (#1545)
* Update `history` view to be more performant - Stop fetching all of history on load of page - Fetch each spec individually when a users selects publication - Break out the diff viewer into a stand alone component Typing - Some types were off for the history page so updated those * Updating to latest `@monaco-editor/react` * I think showing progress while keeping editor is way less shocking UX * Updating how we handle if there is only one pubId Minor tweaks to the UX for loading and comparing Trying to make it more clear the selected item is on the right of the diff * Updating data fetching - We can just use the `published_at` from the main list - Make the function safer so it only calls when there is at least _one_ pub id Editor UX - Keep the viewState while changing the model so the scroll stays while changing publications * Noting down an issue with the underlying lib * Getting the back button working * Some renaming and refactoring - moved stuff into a shared hook to keep things consistent - rename the query params to be specific to this page - * Breaking the hook into two * removing cursor when the item is selected * Add support to ensure selected publication is visible * Scrolling with auto works a bit better for now. Smooth is nice because it brings attention to the list for users.
1 parent bc4518f commit a1a9b21

15 files changed

+542
-248
lines changed

Diff for: package-lock.json

+14-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@jsonforms/material-renderers": "3.2.1",
4646
"@jsonforms/react": "3.2.1",
4747
"@microlink/react-json-view": "^1.23.0",
48-
"@monaco-editor/react": "^4.6.0",
48+
"@monaco-editor/react": "^4.7.0",
4949
"@mui/icons-material": "^5.15.10",
5050
"@mui/lab": "^5.0.0-alpha.165",
5151
"@mui/material": "^5.15.10",

Diff for: src/api/publicationSpecsExt.ts

+37-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export interface PublicationSpecsExt_PublicationHistory {
99
pub_id: string;
1010
detail: null;
1111
published_at: string; //timestamptz
12-
spec: Schema;
1312
spec_type: string;
1413
user_id: string;
1514
catalog_name: string;
@@ -19,15 +18,50 @@ export interface PublicationSpecsExt_PublicationHistory {
1918
user_avatar_url: null;
2019
}
2120

21+
export type PublicationSpecsExt_PubIds = Pick<
22+
PublicationSpecsExt_PublicationHistory,
23+
'pub_id' | 'published_at' | 'detail' | 'user_email'
24+
>;
25+
26+
export interface PublicationSpecsExt_Spec {
27+
pub_id: string;
28+
spec: Schema;
29+
}
30+
2231
export const getPublicationHistoryByCatalogName = (catalogName: string) => {
2332
return supabaseClient
2433
.from(TABLES.PUBLICATION_SPECS_EXT)
25-
.select(`pub_id, published_at, detail, user_email, spec`)
34+
.select(`pub_id, published_at, detail, user_email, published_at`)
2635
.eq('catalog_name', catalogName)
2736
.order('published_at', {
2837
ascending: false,
2938
})
30-
.returns<PublicationSpecsExt_PublicationHistory[]>();
39+
.returns<PublicationSpecsExt_PubIds[]>();
40+
};
41+
42+
export const getPublicationSpecByPublication = (
43+
catalogName: string,
44+
pubIds: [string | null, string | null]
45+
) => {
46+
let query = supabaseClient
47+
.from(TABLES.PUBLICATION_SPECS_EXT)
48+
.select(`pub_id, spec`)
49+
.eq('catalog_name', catalogName);
50+
51+
// If we have both look for both
52+
// Otherwise we're probably looking up a NEW entity and only
53+
// have a single pubId.
54+
if (pubIds[0] && pubIds[1]) {
55+
query = query.in('pub_id', pubIds);
56+
} else {
57+
if (pubIds[0]) {
58+
query = query.eq('pub_id', pubIds[0]);
59+
} else if (pubIds[1]) {
60+
query = query.eq('pub_id', pubIds[1]);
61+
}
62+
}
63+
64+
return query.returns<PublicationSpecsExt_Spec[]>();
3165
};
3266

3367
export const getLiveSpecIdByPublication = (

Diff for: src/components/shared/Entity/Details/History.tsx

-225
This file was deleted.

0 commit comments

Comments
 (0)