Skip to content

Commit a13dd25

Browse files
use base64 compression/decompression
1 parent 808eb3d commit a13dd25

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

components/notion/sources/updated-page/updated-page.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import notion from "../../notion.app.mjs";
22
import sampleEmit from "./test-event.mjs";
33
import base from "../common/base.mjs";
44
import constants from "../common/constants.mjs";
5+
import zlib from "zlib";
56

67
export default {
78
...base,
@@ -69,10 +70,15 @@ export default {
6970
methods: {
7071
...base.methods,
7172
_getPropertyValues() {
72-
return this.db.get("propertyValues");
73+
const compressed = this.db.get("propertyValues");
74+
const buffer = Buffer.from(compressed, "base64");
75+
const decompressed = zlib.inflateSync(buffer).toString();
76+
return JSON.parse(decompressed);
7377
},
7478
_setPropertyValues(propertyValues) {
75-
this.db.set("propertyValues", propertyValues);
79+
const string = JSON.stringify(propertyValues);
80+
const compressed = zlib.deflateSync(string).toString("base64");
81+
this.db.set("propertyValues", compressed);
7682
},
7783
async getPropertiesToCheck() {
7884
if (this.properties?.length) {

0 commit comments

Comments
 (0)