Fix workslots calendar (#5838)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-06-17 19:49:37 +05:00 committed by GitHub
parent b1d7fd03a9
commit bcae079c5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 4 deletions

View File

@ -84,7 +84,6 @@
rank: makeRank(undefined, latestTodo?.rank)
}
)
const _calendar = `${acc._id}_calendar` as Ref<Calendar>
for (const slot of slots) {
await ops.addCollection(time.class.WorkSlot, calendar.space.Calendar, id, time.class.ToDo, 'workslots', {
eventId: generateEventId(),
@ -111,7 +110,7 @@
let _calendar: Ref<Calendar> = `${currentUser._id}_calendar` as Ref<Calendar>
const q = createQuery()
q.query(calendar.class.ExternalCalendar, { default: true, members: currentUser._id }, (res) => {
q.query(calendar.class.ExternalCalendar, { default: true, hidden: false, createdBy: currentUser._id }, (res) => {
if (res.length > 0) {
_calendar = res[0]._id
}

View File

@ -52,7 +52,7 @@
const date = e.detail.date.getTime()
const currentUser = getCurrentAccount() as PersonAccount
const extCalendar = await client.findOne(calendar.class.ExternalCalendar, {
members: currentUser._id,
createdBy: currentUser._id,
hidden: false,
default: true
})

View File

@ -55,7 +55,12 @@
const now = Date.now()
const date = Math.ceil(now / (30 * 60 * 1000)) * (30 * 60 * 1000)
const currentUser = getCurrentAccount() as PersonAccount
const _calendar = `${currentUser._id}_calendar` as Ref<Calendar>
const extCalendar = await client.findOne(calendar.class.ExternalCalendar, {
createdBy: currentUser._id,
hidden: false,
default: true
})
const _calendar = extCalendar ? extCalendar._id : (`${currentUser._id}_calendar` as Ref<Calendar>)
const dueDate = date + defaultDuration
await client.addCollection(time.class.WorkSlot, calendar.space.Calendar, todo._id, todo._class, 'workslots', {
eventId: generateEventId(),