Skip to content

Commit

Permalink
fix: remove redundant console.log-s
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanDavlyatshin committed Aug 5, 2022
1 parent 4ac05b8 commit 472ca15
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 40 deletions.
26 changes: 11 additions & 15 deletions src/common/background-interop/background-connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { repeatAsync } from '../util/repeat-async';
import type { BackgroundConnection, ConnectCallback, DisconnectCallback } from './types';

export async function connect(connectCb: ConnectCallback, disconnectCb: DisconnectCallback) {
const repeatUntilConnect = () => repeatAsync(async () => {
const connection = await connectPort(() => {
const reconnectPromise = repeatUntilConnect();
disconnectCb(reconnectPromise);
const repeatUntilConnect = () =>
repeatAsync(async () => {
const connection = await connectPort(() => {
const reconnectPromise = repeatUntilConnect();
disconnectCb(reconnectPromise);
});
connectCb(connection);
return connection;
});
connectCb(connection);
return connection;
});
return repeatUntilConnect();
}

Expand Down Expand Up @@ -58,12 +59,10 @@ async function connectPort(disconnectCb: () => void): Promise<BackgroundConnecti
console.log('No handler for resource', message.resource);
return;
}
// console.log('PORT RECEIVED MESSAGE', message, 'NOTIFY SUBS', handlers);
handlers.forEach(handler => handler(message.payload));
handlers.forEach((handler) => handler(message.payload));
};

const disconnectHandler = () => {
// console.log('DISCONNECT disconnectHandler');
if (port.onMessage.hasListener(messageHandler)) {
port.onMessage.removeListener(messageHandler);
}
Expand All @@ -76,7 +75,6 @@ async function connectPort(disconnectCb: () => void): Promise<BackgroundConnecti

return {
subscribe: (resource: string, handler: (...params: any) => any, options?: any) => {
// console.log('BG CONNECT SUBSCRIBE', resource, handler, options);
if (!Array.isArray(subs[resource])) {
subs[resource] = [];
}
Expand All @@ -88,9 +86,7 @@ async function connectPort(disconnectCb: () => void): Promise<BackgroundConnecti
}

const unsubscribe = () => {
// console.log('BG CONNECT UNSUB', resource, options);

const index = subs[resource].findIndex(x => x === handler);
const index = subs[resource].findIndex((x) => x === handler);
subs[resource].splice(index, 1); // TODO Does it look kinda iffy?

const noMoreSubsLeft = subs[resource].length === 0;
Expand All @@ -102,7 +98,7 @@ async function connectPort(disconnectCb: () => void): Promise<BackgroundConnecti
return unsubscribe;
},
unsubscribeAll() {
unsubscribeFunctions.forEach(x => x());
unsubscribeFunctions.forEach((x) => x());
unsubscribeFunctions = [];
},
};
Expand Down
1 change: 0 additions & 1 deletion src/content-script/context/active-scope-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const ActiveScopeContext = React.createContext<any>(null);

export const withActiveScopeContext = (WrappedComponent: any) => (props: any) => {
const { data } = useActiveScope();
console.log('withActiveScopeContext', data);
return (
<ActiveScopeContext.Provider value={data}>
<WrappedComponent {...props} />
Expand Down
2 changes: 0 additions & 2 deletions src/content-script/context/agent-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ export const AgentContext = React.createContext<any>(null);

export const withAgentContext = (WrappedComponent: any) => (props: any) => {
const { host, ...otherProps } = props;
console.log('withAgentContext', host, otherProps);
const { data: agent } = useAgentOnHost(host);
console.log('withAgentContext agent', agent);
return (
<AgentContext.Provider value={agent}>
<WrappedComponent {...props} />
Expand Down
1 change: 0 additions & 1 deletion src/content-script/context/session-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const SessionContext = React.createContext<any>(null);

export const withSessionContext = (WrappedComponent: any) => (props: any) => {
const { data } = useSession();
console.log('withSessionContext', data);
return (
<SessionContext.Provider value={data}>
<WrappedComponent {...props} />
Expand Down
18 changes: 6 additions & 12 deletions src/content-script/pages/finished-manual-test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const FinishedManualTest = () => {
<VerticalLine />
<div className="d-flex align-items-center">
<span className="mr-2">Test:</span>
<TestName className="bold" title={session?.testName}>{session?.testName}</TestName>
<TestName className="bold" title={session?.testName}>
{session?.testName}
</TestName>
</div>
<div>
<span className="mr-2">Duration:</span>
Expand All @@ -36,19 +38,11 @@ export const FinishedManualTest = () => {
<span className="mr-1">Scope Coverage:</span>

{agent.adapterType === 'groups' && (
<span
className="bold"
title="Scope coverage for each Agent from Service Group is available in the Admin Panel"
>
<span className="bold" title="Scope coverage for each Agent from Service Group is available in the Admin Panel">
n/a
</span>
)}
{agent.adapterType !== 'groups' && (
<span className="bold">
{percentFormatter(scope?.coverage?.percentage || 0)}
%
</span>
)}
{agent.adapterType !== 'groups' && <span className="bold">{percentFormatter(scope?.coverage?.percentage || 0)}%</span>}
</div>
<Button
size="small"
Expand All @@ -57,7 +51,7 @@ export const FinishedManualTest = () => {
try {
await bgInterop.cleanupTestSession();
} catch (e) {
console.log('cancel recording session failed', e);
// console.log('cancel recording session failed', e);
}
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const ConfirmFinishTest = confirmFinishTest(({ className, setIsConfirming
<div className={className}>
<Form
onSubmit={async (values) => {
console.log('values', values);
updateRequestStatus(true);
await bgInterop.stopTest(values.status);
if (isMounted.current) updateRequestStatus(false);
Expand Down
7 changes: 3 additions & 4 deletions src/content-script/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ const SET_INITIAL = 'SET_INITIAL';
const SET_CORNER = 'SET_CORNER';
const SET_IS_WIDGET_VISIBLE = 'SET_IS_WIDGET_VISIBLE';

export type Action = ReturnType<
typeof savePosition | typeof setInitial | typeof setIsWidgetVisible | typeof setCorner>;
export type Action = ReturnType<typeof savePosition | typeof setInitial | typeof setIsWidgetVisible | typeof setCorner>;

export const setIsWidgetVisible = (data: boolean) => ({ type: SET_IS_WIDGET_VISIBLE, payload: data } as const);
export const savePosition = (position: { x: number; y: number}) => ({ type: SAVE_POSITION, payload: position } as const);
export const savePosition = (position: { x: number; y: number }) => ({ type: SAVE_POSITION, payload: position } as const);
export const setInitial = (initialState: Record<string, any>) => ({ type: SET_INITIAL, payload: initialState } as const);
export const setCorner = (corner: Corner | undefined) => ({ type: SET_CORNER, payload: nextCorner(corner) } as const);

Expand Down Expand Up @@ -42,7 +41,7 @@ export const reducer = (sideEffect: (params: any) => void) => (state: Applicatio
try {
sideEffect(newState);
} catch (e) {
console.log('WARNING', 'side effect failed', e);
// console.warn('drill4j browser extension', e);
}

return newState;
Expand Down
6 changes: 2 additions & 4 deletions src/hooks/util/use-subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ type asyncOp = () => Promise<any>;
type syncOp = () => any;
const noop = () => {};
export function useSubscriptionWithAsyncOptions<T>(
subscribe: (...params: any[]) => Promise<() => void>, getOptions: asyncOp | syncOp | unknown = noop,
subscribe: (...params: any[]) => Promise<() => void>,
getOptions: asyncOp | syncOp | unknown = noop,
): SubscriptionState<T> {
const [data, setData] = useState<T | null>(null);
const [isLoading, setIsLoading] = useState(true);
Expand All @@ -29,7 +30,6 @@ export function useSubscriptionWithAsyncOptions<T>(
let unsubscribe: () => any;

const cleanup = () => {
console.log('ASYNC SUB CLEANUP', getOptions);
isCleanupCalled = true;
unsubscribe && unsubscribe();
};
Expand All @@ -38,9 +38,7 @@ export function useSubscriptionWithAsyncOptions<T>(
try {
const options = typeof getOptions === 'function' ? await (getOptions() as Promise<any>) : getOptions;
if (isCleanupCalled) return;
console.log('ASYNC SUB CALL', getOptions);
unsubscribe = await subscribe((newData: T) => {
console.log('ASYNC SUB UPDATE', getOptions);
setData(newData);
setIsLoading(false);
}, options);
Expand Down

0 comments on commit 472ca15

Please sign in to comment.