Skip to content

Commit 7e4cfa6

Browse files
authored
Fix check watches after protobuf-es change (#71)
1 parent c1c5768 commit 7e4cfa6

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/components/panels/watches.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ export function WatchesPanel(props: PanelProps<PlaygroundPanelLocation>) {
295295
);
296296
}
297297

298+
function notNull(value: string | null): value is string {
299+
return value !== null;
300+
}
301+
298302
const filter = (values: (string | null)[]): string[] => {
299-
const filtered = values.filter((v: string | null) => !!v);
303+
const filtered = values.filter(notNull);
300304
const set = new Set(filtered);
301-
const deduped: string[] = [];
302-
set.forEach((value: string | null) => {
303-
deduped.push(value!);
304-
});
305-
return deduped;
305+
return Array.from(set);
306306
};
307307

308308
function LiveCheckRow(props: {

src/spicedb-common/services/developerservice.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
DeveloperRequestSchema,
2323
DeveloperResponseSchema,
2424
} from "../protodefs/developer/v1/developer_pb";
25-
import { create, toJson } from "@bufbuild/protobuf";
25+
import { create, fromJsonString, toJsonString } from "@bufbuild/protobuf";
2626
import wasmConfig from "../../wasm-config.json";
2727

2828
const WASM_FILE = `/static/main.wasm`;
@@ -226,16 +226,13 @@ class DeveloperServiceRequest {
226226
),
227227
});
228228

229-
const developerRequest = JSON.stringify(
230-
toJson(DeveloperRequestSchema, request),
231-
);
229+
const developerRequest = toJsonString(DeveloperRequestSchema, request);
232230
const encodedResponse: string =
233231
window[ENTRYPOINT_FUNCTION](developerRequest);
234232

235-
const response = create(
236-
DeveloperResponseSchema,
237-
JSON.parse(encodedResponse),
238-
);
233+
const response = fromJsonString(DeveloperResponseSchema, encodedResponse, {
234+
ignoreUnknownFields: true,
235+
});
239236
if (this.operations.length > 0 && response.operationsResults) {
240237
this.operations.forEach((osc, index) => {
241238
const result = response.operationsResults?.results[index];

0 commit comments

Comments
 (0)