aboutsummaryrefslogtreecommitdiff
path: root/src/gapi.js
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-02-03 01:14:45 -0500
committerDeterminant <ted.sybil@gmail.com>2019-02-03 01:14:45 -0500
commit5552d53304a26f53172e1cc0d0f86e01131eaadd (patch)
tree7276c23d174ac84c73de595b16ce841ae7b36f22 /src/gapi.js
parent580990a5eb4a79892c48e3a3fce3386fe80e6cc2 (diff)
use Msg objects
Diffstat (limited to 'src/gapi.js')
-rw-r--r--src/gapi.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/gapi.js b/src/gapi.js
index b5816ca..25d1cbf 100644
--- a/src/gapi.js
+++ b/src/gapi.js
@@ -202,16 +202,18 @@ export class GCalendar {
sync() {
return this.token.then(token => getEvents(this.calId, token, this.syncToken).then(r => {
- this.syncToken = r.nextSyncToken;
- let pm_results = r.results.map(e => e.start ? Promise.resolve(e) : getEvent(this.calId, e.id, token));
- return Promise.all(pm_results).then(results => results.forEach(e => {
- e.start = new Date(e.start.dateTime);
- e.end = new Date(e.end.dateTime);
- if (e.status === 'confirmed')
- this.addEvent(e);
- else if (e.status === 'cancelled')
- this.removeEvent(e);
- }));
+ let pms = r.results.map(e => e.start ? Promise.resolve(e) : getEvent(this.calId, e.id, token));
+ return Promise.all(pms).then(results => {
+ results.forEach(e => {
+ e.start = new Date(e.start.dateTime);
+ e.end = new Date(e.end.dateTime);
+ if (e.status === 'confirmed')
+ this.addEvent(e);
+ else if (e.status === 'cancelled')
+ this.removeEvent(e);
+ });
+ this.syncToken = r.nextSyncToken;
+ });
})).catch(e => {
if (e === GApiError.invalidSyncToken) {
this.syncToken = '';
@@ -260,9 +262,7 @@ export class GCalendar {
return this.token.then(token => getEvents(this.calId, token, null,
this.slotStartDate(query.start).toISOString(),
this.slotEndDate(query.end).toISOString()).then(r => {
- if (this.syncToken === '')
- this.syncToken = r.nextSyncToken;
- return r.results.forEach(e => {
+ r.results.forEach(e => {
if (e.status === 'confirmed')
{
console.assert(e.start);
@@ -271,6 +271,8 @@ export class GCalendar {
this.addEvent(e, true);
}
});
+ if (this.syncToken === '')
+ this.syncToken = r.nextSyncToken;
})).then(() => this.sync())
.then(() => this.getCachedEvents({ start, end }));
}