From 0bb6aa30cdab8806f03acd3f2f0b681d3de7cab8 Mon Sep 17 00:00:00 2001 From: Mattia Cecchini Date: Mon, 4 Nov 2024 01:59:18 +0100 Subject: [PATCH] gzip settings --- CHANGELOG.md | 6 ++++++ package.json | 4 ++-- src/services/message-service.ts | 38 ++++++++++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71c1cf9..519720e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index 7ac1813..f9a79a0 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/services/message-service.ts b/src/services/message-service.ts index ad583d8..3f23e81 100644 --- a/src/services/message-service.ts +++ b/src/services/message-service.ts @@ -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) {} @@ -102,7 +103,20 @@ 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); } @@ -110,8 +124,26 @@ export default class MessageService { 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) {