Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
seancolsen committed Dec 18, 2023
1 parent 7c2e5ed commit 85ed622
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions mathesar_ui/src/systems/connections/generalConnections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,41 +51,15 @@ export const generalConnections: Readable<GeneralConnection[]> = derived(
],
);

// /**
// * The connection to pre-select when asking the user what connection they want
// * to utilize for managing other connections (e.g. creating a new connection).
// */
// export const defaultGeneralConnection = derived(
// generalConnections,
// (connections) => {
// if (connections.length === 0) return undefined;
// const internalConnection = connections.find(
// (connection) => connection.type === 'internal_database',
// );
// if (internalConnection) return internalConnection;
// const userDatabaseConnections = connections.filter(
// isUserDatabaseConnection,
// );

// // Return the connection with the highest ID
// return userDatabaseConnections.reduce((a, b) =>
// a.connection.id > b.connection.id ? a : b,
// );
// },
// );

export function pickDefaultGeneralConnection(connections: GeneralConnection[]) {
if (connections.length === 0) return undefined;
const internalConnection = connections.find(
(connection) => connection.type === 'internal_database',
);
if (internalConnection) return internalConnection;
const userDatabaseConnections = connections.filter(isUserDatabaseConnection);

// Return the connection with the highest ID
return userDatabaseConnections.reduce((a, b) =>
a.connection.id > b.connection.id ? a : b,
);
return connections
.filter(isUserDatabaseConnection)
.reduce((a, b) => (a.connection.id > b.connection.id ? a : b));
}

export function getUsername({ connection }: GeneralConnection): string {
Expand Down

0 comments on commit 85ed622

Please sign in to comment.