Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

Commit

Permalink
fix(shared): added metadata logger box to extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ascariandrea committed Sep 27, 2022
1 parent 217f638 commit dc4937b
Show file tree
Hide file tree
Showing 30 changed files with 1,069 additions and 213 deletions.
1 change: 1 addition & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^11.18.0",
"react-json-view": "^1.21.3",
"ts-endpoint": "^2.0.0",
"ts-endpoint-express": "^2.0.0",
"ts-io-error": "^2.0.0",
Expand Down
27 changes: 20 additions & 7 deletions packages/shared/src/extension/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';
import { ParserFn } from '../providers/parser.provider';
import { HandshakeResponse } from '../models/HandshakeBody';
import { clearCache } from '../providers/dataDonation.provider';
import { FIXED_USER_NAME, initializeKey } from './background/account';
Expand All @@ -16,6 +17,7 @@ import log from './logger';
import HubEvent from './models/HubEvent';
import { ServerLookup } from './models/Message';
import UserSettings from './models/UserSettings';
import { renderUI, RenderUIProps } from './ui';
import { bo } from './utils/browser.utils';

// instantiate a proper logger
Expand Down Expand Up @@ -67,7 +69,12 @@ interface SetupObserverOpts {
onLocationChange: (oldLocation: string, newLocation: string) => void;
}

export interface BootOpts {
export interface BootOpts<
S = any,
M = any,
C = any,
PP extends Record<string, ParserFn<S, any, C>> = any
> {
payload: ServerLookup['payload'];
mapLocalConfig: (
c: UserSettings,
Expand All @@ -79,6 +86,7 @@ export interface BootOpts {
onRegister: (h: Hub<HubEvent>, config: UserSettings) => void;
};
onAuthenticated: (res: any) => void;
ui?: Omit<RenderUIProps<S, M, C, PP>, 'hub'>;
}

/**
Expand Down Expand Up @@ -227,7 +235,12 @@ const serverHandshakeP = (

let loading = false;
let app: App | undefined;
export async function boot(opts: BootOpts): Promise<App> {
export async function boot<
S = any,
M = any,
C = any,
PP extends Record<string, ParserFn<S, any, C>> = any
>(opts: BootOpts<S, M, C, PP>): Promise<App> {
if (app) {
appLog.debug('App already booted!');
return app;
Expand Down Expand Up @@ -316,12 +329,12 @@ export async function boot(opts: BootOpts): Promise<App> {
// register platform specific event handlers
opts.hub.onRegister(opts.hub.hub, config);

// emergency button should be used when a supported with
// UX hack in place didn't see any UX change, so they
// can report the problem and we can handle it.
// initializeEmergencyButton();
// render shared ui if configuration is given
if (opts.ui) {
renderUI({ hub: opts.hub.hub, ...opts.ui });
}

// because the URL has been for sure reloaded, be sure to also
// because the URL has been for sure reloaded, be sure to also clear cache
clearCache();

// send the configuration to the server to register the extension
Expand Down
23 changes: 0 additions & 23 deletions packages/shared/src/extension/tooltip/index.tsx

This file was deleted.

Loading

0 comments on commit dc4937b

Please sign in to comment.