Skip to content

Commit

Permalink
gzip settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mceck committed Nov 4, 2024
1 parent 4f2681c commit 0bb6aa3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to the "clickup-kanbans" extension will be documented in thi

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [1.5.5]

### Added

- feat: gzip settings

## [1.5.4]

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@
]
},
"clickup-kanban.config.vs-config": {
"type": "object",
"type": "string",
"markdownDescription": "Default filters configuration"
},
"clickup-kanban.config.ts-config": {
"type": "object",
"type": "string",
"markdownDescription": "Default filters configuration for timesheets"
}
}
Expand Down
38 changes: 35 additions & 3 deletions src/services/message-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CacheProvider } from '../providers/cache-provider';
import clickupService from './clickup-service';
import loginService from './login-service';
import taskService from './task-service';
import { gzip, unzip } from 'zlib';

export default class MessageService {
constructor(private webview: vscode.Webview) {}
Expand Down Expand Up @@ -102,16 +103,47 @@ export default class MessageService {
const { nonce, global, configName, ...configuration } = query;
this.sendResponse(async () => {
const config = vscode.workspace.getConfiguration('clickup-kanban.config');
await config.update(configName ?? 'vs-config', configuration, global);
let value = configuration;
if (['vs-config', 'ts-config'].includes(configName)) {
const buffer = Buffer.from(JSON.stringify(configuration));
value = await new Promise((res, rej) =>
gzip(buffer, (err, zip) => {
if (err) {
rej(err);
return;
}
res(zip.toString('base64'));
})
);
}
await config.update(configName ?? 'vs-config', value, global);
return configuration;
}, nonce);
}

getConfig(query: any) {
const { nonce, configName } = query;
this.sendResponse(async () => {
const config = vscode.workspace.getConfiguration('clickup-kanban.config');
return config.get(configName ?? 'vs-config');
const config = vscode.workspace
.getConfiguration('clickup-kanban.config')
.get(configName ?? 'vs-config');
if (
['vs-config', 'ts-config'].includes(configName) &&
typeof config === 'string'
) {
const buffer = Buffer.from(config, 'base64');
const unzipped: string = await new Promise((res, rej) =>
unzip(buffer, (err, r) => {
if (err) {
rej(err);
return;
}
res(r.toString());
})
);
return JSON.parse(unzipped);
}
return config;
}, nonce);
}
getViewTasks(query: any) {
Expand Down

0 comments on commit 0bb6aa3

Please sign in to comment.