package Ġcom . th ios in . nov us . screens . submission Ċ Ċ import Ġandroidx . h ilt . lifecycle . ViewModel Inject Ċ import Ġco . zs mb . rain bow cake . base . Rain bow Cake ViewModel Ċ import Ġcom . th ios in . nov us . domain . model . Submission Ċ Ċ class ĠSubmission ViewModel Ġ@ ViewModel Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġsubmission Presenter : ĠSubmission Presenter , Ċ ) Ġ: ĠR ain bow Cake ViewModel < Submission ViewState >( Submission Initial ) Ġ{ ĊĊĠĠĠ Ġfun Ġload ( submission : ĠSubmission , Ġdisplay Width Dp : ĠFloat ) Ġ= Ġexecute Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġready State Ġ= Ġview State Ġas ? ĠSubmission Ready State ĊĊĠĠĠĠĠĠĠ Ġval Ġlogged In Ġ= Ġsubmission Presenter . is LoggedIn () ĊĊĠĠĠĠĠĠĠ Ġval Ġloading With Content State Ġ= Ġready State ?. copy ( loading Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: ĠSubmission Ready State ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsubmission Ġ= Ġsubmission , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcomments Ġ= Ġempty List (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdisplay Width Dp Ġ= Ġdisplay Width Dp , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcan Vote Ġ= Ġlogged In , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġloading Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġview State Ġ= Ġloading With Content State ĊĊĠĠĠĠĠĠĠ Ġval Ġcomments Ġ= Ġsubmission Presenter . get Comments ( submission . id ) ĊĊĠĠĠĠĠĠĠ Ġview State Ġ= Ġloading With Content State . copy ( comments Ġ= Ġcomments , Ġloading Ġ= Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġvote ( fullname : ĠString , Ġlik ed : ĠBoolean ?, Ġis Comment : ĠBoolean Ġ= Ġfalse ) Ġ= Ġexecute Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġold State Ġ= Ġview State Ġas ? ĠSubmission Ready State Ġ?: Ġreturn @ execute ĊĊĠĠĠĠĠĠĠ Ġview State Ġ= Ġold State . copy ( v oting Ġ= Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġval Ġvote Result Ġ= Ġsubmission Presenter . vote ( fullname , Ġlik ed ) ĊĠĠĠĠĠĠĠ Ġif Ġ( vote Result Ġ&& Ġis Comment . not ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġold State . submission . lik ed Ġ= Ġlik ed ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġview State Ġ= Ġold State . copy ( v oting Ġ= Ġfalse ) ĊĠĠĠ Ġ} Ċ } Ċ