Skip to content

Commit e6ddf2c

Browse files
committed
added guard
1 parent 504ed5c commit e6ddf2c

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/schedule/schedulePane.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,18 +1018,25 @@ export const schedulePane = {
10181018
options.set_x = kb.each(subject, ns.sched('option')) // @@@@@ option -> dtstart in future
10191019
options.set_x = options.set_x.map(function (opt) {
10201020
return kb.any(opt, ns.cal('dtstart'))
1021+
}).filter(function (time) {
1022+
return !!time
10211023
})
10221024

10231025
options.set_y = kb.each(subject, ns.sched('response'))
10241026
options.set_y = options.set_y.map(function (resp) {
10251027
return kb.any(resp, ns.dc('author'))
1028+
}).filter(function (author) {
1029+
return !!author
10261030
})
10271031

10281032
const possibleTimes = kb
10291033
.each(invitation, ns.sched('option'))
10301034
.map(function (opt) {
10311035
return kb.any(opt, ns.cal('dtstart'))
10321036
})
1037+
.filter(function (time) {
1038+
return !!time
1039+
})
10331040

10341041
const displayTheMatrix = function () {
10351042
const matrix = div.appendChild(
@@ -1105,6 +1112,7 @@ export const schedulePane = {
11051112
} // @@ may need that
11061113
const selectOptions = {}
11071114
const predicate = ns.sched('availabilty')
1115+
if (!x) return
11081116
const cellSubject = dataPointForNT[x.toNT()]
11091117
const selector = UI.widgets.makeSelectForOptions(
11101118
dom,
@@ -1143,19 +1151,22 @@ export const schedulePane = {
11431151
const dps = kb.each(myResponse, ns.sched('cell'))
11441152
dps.forEach(function (dataPoint) {
11451153
const time = kb.any(dataPoint, ns.cal('dtstart'))
1154+
if (!time) return
11461155
dataPointForNT[time.toNT()] = dataPoint
11471156
})
11481157
}
11491158
for (let j = 0; j < possibleTimes.length; j++) {
1150-
if (dataPointForNT[possibleTimes[j].toNT()]) continue
1159+
const possibleTime = possibleTimes[j]
1160+
if (!possibleTime) continue
1161+
if (dataPointForNT[possibleTime.toNT()]) continue
11511162
const dataPoint = $rdf.sym(id + '_' + j)
11521163
insertables.push(
11531164
$rdf.st(myResponse, ns.sched('cell'), dataPoint, doc)
11541165
)
11551166
insertables.push(
1156-
$rdf.st(dataPoint, ns.cal('dtstart'), possibleTimes[j], doc)
1167+
$rdf.st(dataPoint, ns.cal('dtstart'), possibleTime, doc)
11571168
) // @@
1158-
dataPointForNT[possibleTimes[j].toNT()] = dataPoint
1169+
dataPointForNT[possibleTime.toNT()] = dataPoint
11591170
}
11601171
if (insertables.length) {
11611172
kb.updater.update([], insertables, function (

0 commit comments

Comments
 (0)