Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4da94ef
fix: remove some of the jank around our core App component
Parkreiner May 2, 2024
9986024
refactor: scope navigation logic more aggressively
Parkreiner May 2, 2024
7004c9c
refactor: add explicit return type to useAuthenticated
Parkreiner May 2, 2024
ebfaec5
refactor: clean up ProxyContext code
Parkreiner May 2, 2024
1192eb3
wip: add code for consolidating the HTML metadata
Parkreiner May 2, 2024
bbe2ae0
refactor: clean up hook logic
Parkreiner May 2, 2024
1c41937
refactor: rename useHtmlMetadata to useEmbeddedMetadata
Parkreiner May 2, 2024
79e9c45
fix: correct names that weren't updated
Parkreiner May 2, 2024
81f2cd9
fix: update type-safety of useEmbeddedMetadata further
Parkreiner May 2, 2024
390418f
wip: switch codebase to use metadata hook
Parkreiner May 3, 2024
486f292
Merge branch 'main' into mes/login-fix
Parkreiner May 3, 2024
b77af73
Merge branch 'mes/login-fix' of https://github.com/coder/coder into m…
Parkreiner May 3, 2024
e072f7a
refactor: simplify design of metadata hook
Parkreiner May 3, 2024
2a58322
fix: update stray type mismatches
Parkreiner May 3, 2024
b55abb7
fix: more type fixing
Parkreiner May 3, 2024
c45e1b7
fix: resolve illegal invocation error
Parkreiner May 3, 2024
2a63c1d
fix: get metadata issue resolved
Parkreiner May 3, 2024
4d3b155
fix: update comments
Parkreiner May 3, 2024
8067e77
chore: add unit tests for MetadataManager
Parkreiner May 3, 2024
5e6e974
fix: beef up tests
Parkreiner May 3, 2024
772b96f
fix: update typo in tests
Parkreiner May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: clean up hook logic
  • Loading branch information
Parkreiner committed May 2, 2024
commit bbe2ae0a6f686f20a63bdeb6c1857ef83160cb84
18 changes: 10 additions & 8 deletions site/src/hooks/useHtmlMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import type {
* This is the set of values that are currently being exposed to the React
* application during production. These values are embedded via the Go server,
* so they will never exist when using a JavaScript runtime for the backend
*
* If you need to add a new type of metadata value, add a new property to the
* type alias here, and then rest of the file should light up with errors for
* what else needs to be adjusted
*/
type SourceHtmlMetadata = Readonly<{
user: User;
Expand Down Expand Up @@ -106,17 +110,15 @@ export class MetadataManager implements MetadataManagerApi {
return;
}

const metadataNode = this.trackedMetadataNodes.get(key);
metadataNode?.remove();
this.trackedMetadataNodes.delete(key);

this.metadata = {
...this.metadata,
[key]: undefined,
};

const metadataNode = this.trackedMetadataNodes.get(key);
if (metadataNode !== undefined) {
metadataNode.remove();
this.trackedMetadataNodes.delete(key);
}

this.notifySubscriptionsOfStateChange();
};
}
Expand All @@ -140,14 +142,14 @@ export function makeUseHtmlMetadata(
manager.getMetadata,
);

const result = useMemo<UseHtmlMetadataResult>(() => {
const stableMetadataResult = useMemo<UseHtmlMetadataResult>(() => {
return {
metadata,
clearMetadataByKey: manager.clearMetadataByKey,
};
}, [metadata]);

return result;
return stableMetadataResult;
};
}

Expand Down