File tree Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -3,19 +3,21 @@ use super::{Calendar, UserDatabase};
3
3
impl UserDatabase {
4
4
pub async fn get_calendar (
5
5
& self ,
6
- calendar_id : impl AsRef < str > ,
7
- ) -> Result < Calendar , crate :: Error > {
6
+ id : impl AsRef < str > ,
7
+ ) -> Result < Option < Calendar > , crate :: Error > {
8
8
let conn = self . conn ( ) ?;
9
9
10
10
let mut rows = conn
11
- . query (
12
- "SELECT * FROM calendars WHERE id = ?" ,
13
- vec ! [ calendar_id. as_ref( ) ] ,
14
- )
11
+ . query ( "SELECT * FROM calendars WHERE id = ?" , vec ! [ id. as_ref( ) ] )
15
12
. await ?;
16
- let row = rows. next ( ) . await ?. unwrap ( ) ;
17
- let calendar: Calendar = libsql:: de:: from_row ( & row) ?;
18
- Ok ( calendar)
13
+
14
+ match rows. next ( ) . await ? {
15
+ Some ( row) => {
16
+ let calendar: Calendar = libsql:: de:: from_row ( & row) ?;
17
+ Ok ( Some ( calendar) )
18
+ }
19
+ None => Ok ( None ) ,
20
+ }
19
21
}
20
22
21
23
pub async fn list_calendars (
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ async getEvent(id: string) : Promise<Event | null> {
13
13
async listEvents ( filter : ListEventFilter | null ) : Promise < Event [ ] > {
14
14
return await TAURI_INVOKE ( "plugin:db|list_events" , { filter } ) ;
15
15
} ,
16
- async getCalendar ( calendarId : string ) : Promise < Calendar > {
16
+ async getCalendar ( calendarId : string ) : Promise < Calendar | null > {
17
17
return await TAURI_INVOKE ( "plugin:db|get_calendar" , { calendarId } ) ;
18
18
} ,
19
19
async listCalendars ( userId : string ) : Promise < Calendar [ ] > {
Original file line number Diff line number Diff line change 4
4
pub async fn get_calendar (
5
5
state : tauri:: State < ' _ , crate :: ManagedState > ,
6
6
calendar_id : String ,
7
- ) -> Result < hypr_db_user:: Calendar , String > {
7
+ ) -> Result < Option < hypr_db_user:: Calendar > , String > {
8
8
let guard = state. lock ( ) . await ;
9
9
10
10
let db = guard
You can’t perform that action at this time.
0 commit comments