package Ġcom . swap card . apps . mov i eb rowser . android . network Ċ Ċ import Ġcom . swap card . apps . mov i eb rowser . android . model . Movie Ċ import Ġcom . swap card . apps . mov i eb rowser . android . repository . Favorite Movie DataSource Ċ import Ġcom . swap card . apps . mov i eb rowser . android . repository . Movie DataSource Ċ import Ġcom . swap card . apps . mov i eb rowser . android . repository . Movie DataSource . Similar Movies Load State Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . flow . Flow Ċ import Ġkotlinx . coroutines . flow . first Ċ import Ġkotlinx . coroutines . flow . flow Ċ import Ġkotlinx . coroutines . with Context Ċ Ċ class ĠGraphQL Movie DataSource ( ĊĠĠĠ Ġprivate Ġval Ġapi Service : ĠGraphQL ApiService , ĊĠĠĠ Ġprivate Ġval Ġfavorite Movie DataSource : ĠF avorite Movie DataSource Ċ ) Ġ: ĠMovie DataSource Ġ{ ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġget Movie ( id : ĠLong ): ĠFlow < Movie > Ġ= Ġwith Context ( Dispatch ers . IO ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfavor ites Ġ= Ġfavorite Movie DataSource . get Favorite Movies (). first () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġmovie Ġ-> Ġmovie . id Ġ}. toSet () ĊĠĠĠĠĠĠĠ Ġreturn @ with Context Ġapi Service . get Movie ( id , Ġfavor ites ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġget Similar Movies ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmovie : ĠMovie ĊĠĠĠ Ġ): ĠFlow < Similar Movies Load State > Ġ= Ġwith Context ( Dispatch ers . IO ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfavor ites Ġ= Ġfavorite Movie DataSource . get Favorite Movies (). first () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġfavorite Movie Ġ-> Ġfavorite Movie . id Ġ}. toSet () ĊĠĠĠĠĠĠĠ Ġreturn @ with Context Ġflow Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġemit ( Similar Movies Load State . Loading ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġsimilar Movies : ĠList < Movie > ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsimilar Movies Ġ= Ġapi Service . similar Movies ( movie , Ġfavor ites ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġemit ( Similar Movies Load State . Loaded ( similar Movies )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġemit ( Similar Movies Load State . Error ( e )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ