Fix calendar errors

pull/1/head
yflory 4 years ago
parent 1c0625eb29
commit 562575ee02

@ -554,12 +554,17 @@ ctx.calendars[channel] = {
return void cb({error: err.error}); return void cb({error: err.error});
} }
// Add the calendar and call back // Add the calendar and call back
c[cal.channel] = cal; // Wait for the metadata to be stored (channel fully ready) before adding it
var pin = store.pin || ctx.pinPads; // to our store
pin([cal.channel], function (res) { var ctxCal = ctx.calendars[cal.channel];
if (res && res.error) { console.error(res.error); } Realtime.whenRealtimeSyncs(ctxCal.lm.realtime, function () {
c[cal.channel] = cal;
var pin = store.pin || ctx.pinPads;
pin([cal.channel], function (res) {
if (res && res.error) { console.error(res.error); }
});
ctx.Store.onSync(store.id, cb);
}); });
ctx.Store.onSync(store.id, cb);
}); });
}; };
var updateCalendar = function (ctx, data, cId, cb) { var updateCalendar = function (ctx, data, cId, cb) {
@ -635,7 +640,8 @@ ctx.calendars[channel] = {
var newC; var newC;
if (changes.calendarId) { if (changes.calendarId) {
newC = ctx.calendars[changes.calendarId]; newC = ctx.calendars[changes.calendarId];
if (!newC || !newC.proxy || !newC.proxy.content) { return void cb({error: "ENOENT"}); } if (!newC || !newC.proxy) { return void cb({error: "ENOENT"}); }
newC.proxy.content = newC.proxy.content || {};
} }
Object.keys(changes).forEach(function (key) { Object.keys(changes).forEach(function (key) {

Loading…
Cancel
Save