Skip to content

Commit

Permalink
Handle opened table
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeniau committed Mar 5, 2024
1 parent ee8f125 commit 793c4bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/configuration/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type Configuration = {
export type ConnectionAppState = {
isActive: boolean; // TODO not handled yet
activeDatabase: string;
openedTable: string; // TODO not handled yet
openedTable: string;
};

export type EncryptedConnectionObject = {
Expand Down
8 changes: 5 additions & 3 deletions src/renderer/routes/connections.$connectionName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ export async function loader({ params, request }: RouteParams) {

const configuration = await window.config.getConfiguration();

const configDatabase =
configuration.connections[connectionName]?.appState?.activeDatabase;
const { activeDatabase: configDatabase, openedTable } =
configuration.connections[connectionName]?.appState || {};

const activeDatabase = configDatabase || databaseList[0].Database;

// redirect to the current database if we are not on a "database" page
const expectedUrl = `/connections/${connectionName}/${activeDatabase}`;
const expectedUrl = `/connections/${connectionName}/${activeDatabase}${
openedTable ? `/${openedTable}` : ''
}`;

if (!request.url.endsWith(expectedUrl)) {
return redirect(expectedUrl);
Expand Down

0 comments on commit 793c4bf

Please sign in to comment.