Skip to content

Commit a946b5e

Browse files
committed
widgets: properly set buffers -- at least now bqplot works
1 parent 2200a24 commit a946b5e

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

src/packages/frontend/jupyter/widgets/manager2.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,6 @@ export class WidgetManager {
239239
A simple example that uses buffers is this image one:
240240
https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html#image
241241
*/
242-
243-
console.log("TEMPORARILY skipping buffers change!!");
244-
return;
245-
246242
const model = await this.manager.get_model(model_id);
247243
const { buffer_paths, buffers } =
248244
await this.ipywidgets_state.get_model_buffers(model_id);
@@ -254,16 +250,24 @@ export class WidgetManager {
254250
// TODO/concern: what if buffer_paths is deeper (length > 1)?
255251
// Will that break something? We do set things properly later.
256252
const key = buffer_paths[i][0];
257-
if (deserialized_state[key] == null) {
253+
const buffer = buffers[i];
254+
if (deserialized_state[key] == null || buffer == null) {
258255
change[key] = null;
259256
continue;
260257
}
261-
const buffer = buffers[i];
262-
const s = serializers[key]?.serialize(deserialized_state[key]) ?? {};
263-
s.value = { buffer };
258+
let s;
259+
const f = serializers[key];
260+
if (f != null) {
261+
s = f.serialize(deserialized_state[key]);
262+
s.value = { buffer };
263+
s = f.deserialize(s);
264+
} else {
265+
s = { ...deserialized_state[key], value: buffer };
266+
}
264267
change[key] = s;
265268
}
266269
log("handleBuffersChange: ", model_id, change);
270+
window.x = { model, model_id, change };
267271
model.set_state(change);
268272
};
269273

src/packages/util/db-schema/syncstring-schema.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Table({
120120
} else {
121121
cb(err);
122122
}
123-
}
123+
},
124124
);
125125
},
126126
},
@@ -159,7 +159,7 @@ Table({
159159
old_val,
160160
new_val,
161161
account_id,
162-
cb
162+
cb,
163163
);
164164
},
165165
},
@@ -340,7 +340,7 @@ Table({
340340
obj,
341341
account_id,
342342
project_id,
343-
cb
343+
cb,
344344
);
345345
},
346346
},
@@ -366,7 +366,7 @@ Table({
366366
obj,
367367
account_id,
368368
project_id,
369-
cb
369+
cb,
370370
);
371371
},
372372
before_change(_db, old_val, new_val, _account_id, cb) {
@@ -381,7 +381,7 @@ Table({
381381
old_val.user_id !== new_val.user_id
382382
) {
383383
cb(
384-
`you may not change the author of a patch from ${old_val.user_id} to ${new_val.user_id}`
384+
`you may not change the author of a patch from ${old_val.user_id} to ${new_val.user_id}`,
385385
);
386386
return;
387387
}
@@ -493,7 +493,7 @@ Table({
493493
obj,
494494
account_id,
495495
project_id,
496-
cb
496+
cb,
497497
);
498498
},
499499
},
@@ -515,7 +515,7 @@ Table({
515515
obj,
516516
account_id,
517517
project_id,
518-
cb
518+
cb,
519519
);
520520
},
521521
},
@@ -566,7 +566,7 @@ Table({
566566
obj.string_id,
567567
account_id,
568568
project_id,
569-
cb
569+
cb,
570570
);
571571
},
572572
},
@@ -588,7 +588,7 @@ Table({
588588
obj.string_id,
589589
account_id,
590590
project_id,
591-
cb
591+
cb,
592592
);
593593
},
594594
},
@@ -637,7 +637,7 @@ Table({
637637
obj.string_id,
638638
account_id,
639639
project_id,
640-
cb
640+
cb,
641641
);
642642
},
643643
},
@@ -659,7 +659,7 @@ Table({
659659
obj.string_id,
660660
account_id,
661661
project_id,
662-
cb
662+
cb,
663663
);
664664
},
665665
},
@@ -709,11 +709,12 @@ Table({
709709
obj.string_id,
710710
account_id,
711711
project_id,
712-
cb
712+
cb,
713713
);
714714
},
715715
},
716716
set: {
717+
delete: true,
717718
fields: {
718719
string_id: true,
719720
model_id: true,
@@ -731,7 +732,7 @@ Table({
731732
obj.string_id,
732733
account_id,
733734
project_id,
734-
cb
735+
cb,
735736
);
736737
},
737738
},

0 commit comments

Comments
 (0)