Skip to content

Commit

Permalink
Use newer config APIs from base
Browse files Browse the repository at this point in the history
Signed-off-by: Liam Barry Allan <[email protected]>
  • Loading branch information
worksofliam committed Nov 7, 2022
1 parent 1be78c5 commit a6070a2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/views/schemaBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ module.exports = class schemaBrowser {
vscode.commands.registerCommand(`vscode-db2i.addSchemaToSchemaBrowser`, async () => {
const config = instance.getConfig();

const schemas = config.get(`databaseBrowserList`) || [];
const schemas = config[`databaseBrowserList`] || [];

const newSchema = await vscode.window.showInputBox({
prompt: `Library to add to Database Browser`
});

if (newSchema && !schemas.includes(newSchema.toUpperCase())) {
schemas.push(newSchema.toUpperCase());
await config.set(`databaseBrowserList`, schemas);
config[`databaseBrowserList`] = schemas;
await instance.setConfig(config);
this.refresh();
}
}),
Expand All @@ -76,14 +77,14 @@ module.exports = class schemaBrowser {
//Running from right click
const config = instance.getConfig();

let schemas = config.get(`databaseBrowserList`);
let schemas = config[`databaseBrowserList`];

let index = schemas.findIndex(file => file.toUpperCase() === node.schema)
if (index >= 0) {
schemas.splice(index, 1);
}

await config.set(`databaseBrowserList`, schemas);
await instance.setConfig(config);
this.refresh();
}
}),
Expand Down Expand Up @@ -126,7 +127,8 @@ module.exports = class schemaBrowser {
const currentLibrary = config.currentLibrary.toUpperCase();

if (schema && schema !== currentLibrary) {
await config.set(`currentLibrary`, schema);
config.currentLibrary = schema;
await instance.setConfig(config);
}

vscode.window.showInformationMessage(`Current schema set to ${schema}.`);
Expand Down Expand Up @@ -222,7 +224,7 @@ module.exports = class schemaBrowser {
if (connection) {
const config = instance.getConfig();

const libraries = config.get(`databaseBrowserList`) || [];
const libraries = config[`databaseBrowserList`] || [];

for (let library of libraries) {
items.push(new Schema(library));
Expand Down

0 comments on commit a6070a2

Please sign in to comment.