Skip to content

Commit e304e3f

Browse files
kalvinnchauam
andauthored
feat: persist sidebar preferences in packaged desktop (#440)
Signed-off-by: am <6e30cd56c30e030cd31bb0939b94a7c257c9a09d5ba2d92cf2735da45629f248@buzz.block.builderlab.xyz> Co-authored-by: am <6e30cd56c30e030cd31bb0939b94a7c257c9a09d5ba2d92cf2735da45629f248@buzz.block.builderlab.xyz>
1 parent b2f245e commit e304e3f

20 files changed

Lines changed: 1402 additions & 101 deletions

‎Cargo.lock‎

Lines changed: 87 additions & 78 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dev/relay-broker.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import {
6868
assertSidebarAssignmentIntent,
6969
mutateSidebarAssignment,
7070
SIDEBAR_REQUEST_BYTES,
71+
SIDEBAR_HEAD_BYTES,
7172
SIDEBAR_UPLOAD_MS,
7273
SIDEBAR_UPLOAD_SLOTS,
7374
} from "./sidebar-preferences.mjs";
@@ -127,7 +128,6 @@ function validProfilePicture(value) {
127128
const MAX_FILTERS = 4,
128129
MAX_LIMIT = 500,
129130
MAX_INFLIGHT = 6,
130-
SIDEBAR_HEAD_BYTES = SIDEBAR_REQUEST_BYTES + 4096,
131131
UPSTREAM_TIMEOUT_MS = 20000,
132132
KEEPALIVE_MS = 60000;
133133

‎dev/sidebar-mutes-broker.test.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createHash } from "node:crypto";
33
import { afterEach, expect, it } from "vitest";
44
import { brokerSocket, openBrokerSocket } from "../tests/broker-socket.mjs";
55
import { generateSecretKey, getPublicKey, verifyEvent } from "nostr-tools";
6+
import { SIDEBAR_HEAD_BYTES } from "./sidebar-preferences.mjs";
67
import { relayBrokerPlugin } from "./relay-broker.mjs";
78
import { prepareSidebarMute } from "./sidebar-mutes.mjs";
89
import { connectBrokerTransport } from "../src/features/relay/transport.ts";
@@ -179,7 +180,7 @@ it.each(["query", "oversized", "rejection", "disconnect", "conflict"])(
179180
if (failure === "query")
180181
h.failQuery(new Response("failed", { status: 503 }));
181182
if (failure === "oversized")
182-
h.failQuery(new Response(`[${" ".repeat(270000)}]`));
183+
h.failQuery(new Response(`[${" ".repeat(SIDEBAR_HEAD_BYTES)}]`));
183184
if (["rejection", "disconnect"].includes(failure))
184185
h.failPublication(failure);
185186
if (failure === "conflict") h.conflict();

‎dev/sidebar-preference-writes.test.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
nip44,
88
verifyEvent,
99
} from "nostr-tools";
10+
import { SIDEBAR_HEAD_BYTES } from "./sidebar-preferences.mjs";
1011
import { relayBrokerPlugin } from "./relay-broker.mjs";
1112
import { prepareSidebarStar } from "./sidebar-stars.mjs";
1213
import { connectBrokerTransport } from "../src/features/relay/transport.ts";
@@ -174,7 +175,7 @@ it.each(["query", "oversized", "publication", "receipt", "conflict"])(
174175
if (failure === "query")
175176
h.failQuery(new Response("failed", { status: 503 }));
176177
if (failure === "oversized")
177-
h.failQuery(new Response(`[${" ".repeat(270000)}]`));
178+
h.failQuery(new Response(`[${" ".repeat(SIDEBAR_HEAD_BYTES)}]`));
178179
if (failure === "publication")
179180
h.failPublication(new Response("failed", { status: 503 }));
180181
if (failure === "receipt")

‎dev/sidebar-preferences.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
SIDEBAR_COORDINATES,
55
} from "../src/features/relay/sidebar-preferences.ts";
66

7-
export const SIDEBAR_REQUEST_BYTES = 256 * 1024;
7+
export const SIDEBAR_REQUEST_BYTES = 768 * 1024; // Four bounded encrypted coordinates.
8+
export const SIDEBAR_HEAD_BYTES = 192 * 1024 + 4096; // One signed coordinate plus response framing.
89
export const SIDEBAR_UPLOAD_SLOTS = 2;
910
export const SIDEBAR_UPLOAD_MS = 10_000;
1011
/** Local host decoder, deliberately not an arbitrary NIP-44 decrypt capability. */

0 commit comments

Comments
 (0)