Skip to content

Commit 27a5d74

Browse files
committed
chore(connections): rename prop; add comments; more cleanup
1 parent f5c271e commit 27a5d74

File tree

5 files changed

+41
-31
lines changed

5 files changed

+41
-31
lines changed

packages/compass-connections/src/index.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,42 @@ export type { ConnectionFeature } from './utils/connection-supports';
2626
export { connectionSupports } from './utils/connection-supports';
2727

2828
const ConnectionsComponent: React.FunctionComponent<{
29+
/**
30+
* Application name, will be passed to the driver during connection
31+
*/
2932
appName: string;
33+
/**
34+
* Callback prop that should resolve with any extra connection information to
35+
* be added to the connection tracking
36+
*/
3037
onExtraConnectionDataRequest: (
3138
connectionInfo: ConnectionInfo
3239
) => Promise<[ExtraConnectionDataForTelemetry, string | null]>;
40+
/**
41+
* Callback prop that might optionally resolve with the connectionInfo object
42+
* to be automatically connected to as soon as plugin is activated.
43+
* ConnectionStorage argument can be used to pick connectionInfo from the list
44+
* of existing connections
45+
*/
3346
onAutoconnectInfoRequest?: (
3447
connectionStorage: ConnectionStorage
3548
) => Promise<ConnectionInfo | undefined>;
36-
allowAutoconnectInfoReconnect?: boolean;
49+
/**
50+
* By default any connection returned by `onAutoconnectInfoRequest` will be
51+
* automatically connected. This property can be used to disable "reconnect"
52+
* if connection with the matching id was explicitly disconnected by the user
53+
* in the UI before in the same session. Currently this is only behavior of
54+
* Compass desktop.
55+
*/
56+
doNotReconnectDisconnectedAutoconnectInfo?: boolean;
57+
/**
58+
* Can be used to override default connection function
59+
*/
3760
connectFn?: typeof devtoolsConnect | undefined;
61+
/**
62+
* Can be used to provide preloaded connections instead of triggering loading
63+
* connections on plugin activate
64+
*/
3865
preloadStorageConnectionInfos?: ConnectionInfo[];
3966
}> = ({ children }) => {
4067
return (
@@ -71,7 +98,7 @@ const CompassConnectionsPlugin = registerHadronPlugin(
7198
void store.dispatch(
7299
autoconnectCheck(
73100
initialProps.onAutoconnectInfoRequest,
74-
initialProps.allowAutoconnectInfoReconnect
101+
initialProps.doNotReconnectDisconnectedAutoconnectInfo
75102
)
76103
);
77104
}

packages/compass-connections/src/stores/connections-store-redux.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ export const autoconnectCheck = (
14031403
getAutoconnectInfo: (
14041404
connectionStorage: ConnectionStorage
14051405
) => Promise<ConnectionInfo | undefined>,
1406-
allowAutoconnectInfoReconnect = true
1406+
doNotReconnectDisconnectedAutoconnectInfo = false
14071407
): ConnectionsThunkAction<
14081408
Promise<void>,
14091409
ConnectionAutoconnectCheckAction | ConnectionAttemptErrorAction
@@ -1421,16 +1421,17 @@ export const autoconnectCheck = (
14211421
);
14221422
const connectionInfo = await getAutoconnectInfo(connectionStorage);
14231423
if (
1424-
allowAutoconnectInfoReconnect ||
1425-
getSessionConnectionStatus(connectionInfo?.id) !== 'disconnected'
1424+
doNotReconnectDisconnectedAutoconnectInfo &&
1425+
getSessionConnectionStatus(connectionInfo?.id) === 'disconnected'
14261426
) {
1427-
dispatch({
1428-
type: ActionTypes.ConnectionAutoconnectCheck,
1429-
connectionInfo: connectionInfo,
1430-
});
1431-
if (connectionInfo) {
1432-
void dispatch(connect(connectionInfo));
1433-
}
1427+
return;
1428+
}
1429+
dispatch({
1430+
type: ActionTypes.ConnectionAutoconnectCheck,
1431+
connectionInfo: connectionInfo,
1432+
});
1433+
if (connectionInfo) {
1434+
void dispatch(connect(connectionInfo));
14341435
}
14351436
} catch (err) {
14361437
dispatch(connectionAttemptError(null, err));

packages/compass-connections/src/stores/store-context.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -326,20 +326,6 @@ export function useConnectionInfoRefForId(connectionId: ConnectionId): {
326326
return ref;
327327
}
328328

329-
/**
330-
* @deprecated exposed for compat with old connections store interface, should
331-
* never be used anywhere else
332-
*/
333-
export function useConnectionsState() {
334-
return useSelector((state) => state, {
335-
// These warnings are very noisy. We know this selector is bad, but there is
336-
// no way to reimplement old connections store without it and we're going to
337-
// remove it soon anyway
338-
stabilityCheck: 'never',
339-
noopCheck: 'never',
340-
});
341-
}
342-
343329
export function useConnectionsColorList(): {
344330
id: ConnectionId;
345331
color: string | undefined;

packages/compass/src/app/components/home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function HomeWithConnections({
148148
appName={props.appName}
149149
onExtraConnectionDataRequest={getExtraConnectionData}
150150
onAutoconnectInfoRequest={onAutoconnectInfoRequest}
151-
allowAutoconnectInfoReconnect={false}
151+
doNotReconnectDisconnectedAutoconnectInfo
152152
>
153153
<Home {...props}></Home>
154154
</CompassConnections>

packages/compass/src/app/components/workspace.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ export default function Workspace({
7878
[appName, getConnectionInfoById, onActiveWorkspaceTabChange]
7979
);
8080

81-
useEffect(() => {
82-
updateTitle(appName);
83-
}, [appName]);
84-
8581
return (
8682
<WorkspacesProvider
8783
value={[

0 commit comments

Comments
 (0)