list shared calendar from new api

This commit is contained in:
Peter Maquiran
2024-06-06 15:13:03 +01:00
parent 74a365b3cf
commit 14976cc159
7 changed files with 109 additions and 109 deletions
@@ -177,7 +177,7 @@ export class AgendaDataRepositoryService {
if(result.isOk()) {
await this.agendaLocalDataSourceService.clearSharedCalendar()
if(result.value?.data) {
return await this.agendaLocalDataSourceService.create(result.value.data)
return await this.agendaLocalDataSourceService.bulkCreate(result.value.data)
} else {
return result
}
@@ -186,4 +186,12 @@ export class AgendaDataRepositoryService {
}
}
getShareCalendarItemsLive() {
return this.agendaLocalDataSourceService.getShareCalendarItemsLive()
}
async geCalendars() {
return await this.agendaLocalDataSourceService.geCalendars()
}
}
@@ -4,6 +4,7 @@ import { Dexie, EntityTable, liveQuery } from 'Dexie';
import { SharedCalendarListItemOutputDTO, SharedCalendarListOutputDTO } from './model/sharedCalendarOutputDTO';
import { any, z } from 'zod';
import { err, ok } from 'neverthrow';
import { from } from 'rxjs';
const tableScharedCalendar = z.object({
@@ -34,17 +35,16 @@ export class AgendaLocalDataSourceService {
constructor() { }
async create(data: SharedCalendarListItemOutputDTO[]) {
async bulkCreate(data: SharedCalendarListItemOutputDTO[]) {
// db.eve
try {
const result = AgendaDataSource.shareCalendar.bulkAdd(data)
const result = await AgendaDataSource.shareCalendar.bulkAdd(data)
return ok(result)
} catch (e) {
return err(false)
}
}
clearSharedCalendar() {
// db.eve
try {
@@ -53,6 +53,15 @@ export class AgendaLocalDataSourceService {
} catch (e) {
return err(false)
}
}
async geCalendars() {
return await AgendaDataSource.shareCalendar.toArray()
}
getShareCalendarItemsLive() {
return from(liveQuery( () => {
return AgendaDataSource.shareCalendar.toArray()
}))
}
}