package Ġcom . g no e mes . shim ori . data . repositories . manga Ċ Ċ import Ġcom . g no e mes . shim ori . base . di . Sh ik im ori Ċ import Ġcom . g no e mes . shim ori . base . entities . Success Ċ import Ġcom . g no e mes . shim ori . base . extensions . instant In Past Ċ import Ġcom . g no e mes . shim ori . data . repositories . user . Sh ik im ori UserRepository Ċ import Ġcom . g no e mes . shim ori . data _ base . sources . M anga DataSource Ċ import Ġcom . g no e mes . shim ori . model . rate . Rate Sort Ċ import Ġcom . g no e mes . shim ori . model . rate . Rate Status Ċ import Ġorg . th reet en . bp . Instant Ċ import Ġjavax . inject . Inject Ċ import Ġjavax . inject . Singleton Ċ Ċ @ Singleton Ċ class ĠM anga Repository Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġm anga Store : ĠM anga Store , ĊĠĠĠ Ġ@ Sh ik im ori Ġprivate Ġval Ġm anga DataSource : ĠM anga DataSource , ĊĠĠĠ Ġprivate Ġval Ġuser Repository : ĠSh ik im ori UserRepository , ĊĠĠĠ Ġprivate Ġval Ġrates Last Request Store : ĠM anga With Status Last Request Store Ċ ) Ġ{ ĊĊĠĠĠ Ġfun Ġobserve ById ( id Ġ: ĠLong ) Ġ= Ġm anga Store . observe ById ( id ) ĊĠĠĠ Ġfun Ġobserve By Status For Paging ( status : ĠRate Status , Ġsort : ĠRate Sort ) Ġ= ĊĠĠĠĠĠĠĠ Ġm anga Store . observe By Status For Paging ( status , Ġsort ) ĊĊĠĠĠ Ġfun Ġobserve Pin ned () Ġ= Ġm anga Store . observe Pin ned () ĊĊĠĠĠ Ġsuspend Ġfun Ġquery Random By Status ( status : ĠRate Status ?) Ġ= Ġm anga Store . query Random By Status ( status ) ĊĊĠĠĠ Ġsuspend Ġfun Ġupdate My M anga With Status ( status : ĠRate Status ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuser Ġ= Ġuser Repository . get My User Short () Ġ?: Ġreturn ĊĊĠĠĠĠĠĠĠ Ġval Ġresults Ġ= Ġm anga DataSource . getM anga With Status ( user , Ġstatus ) ĊĠĠĠĠĠĠĠ Ġif Ġ( results Ġis ĠSuccess Ġ&& Ġresults . data . isNotEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġm ang as Ġ= Ġresults . data . filter Not Ġ{ Ġit . type Ġ== Ġnull Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġm anga Store . update ( m ang as ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrates Last Request Store . update Last Request () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun Ġneed Update M anga With Status ( expiry : ĠInstant Ġ= Ġinstant In Past ( minutes Ġ= Ġ 5 )): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġrates Last Request Store . is Request Before ( expiry ) ĊĠĠĠ Ġ} Ċ Ċ }