mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
list shared calendar from new api
This commit is contained in:
@@ -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()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user