package Ġcom . github . ll max im ll . m yst ory is my world . presentation . explore . other profile . view model Ċ Ċ import Ġandroidx . lifecycle .* Ċ import Ġandroidx . work . Work Manager Ċ import Ġcom . github . ll max im ll . m yst ory is my world . data . graph . repository . Graph Repository Impl Ċ import Ġcom . github . ll max im ll . m yst ory is my world . data . user . repository . UserRepository Impl Ċ import Ġcom . github . ll max im ll . m yst ory is my world . domain . models . graph . Graph Data Info Ċ import Ġcom . github . ll max im ll . m yst ory is my world . domain . models . user . UserDetails Ċ import Ġcom . github . ll max im ll . m yst ory is my world . presentation . states . Fetch State Ċ import Ġcom . github . ll max im ll . m yst ory is my world . utils . Network Status Ċ import Ġcom . github . ll max im ll . m yst ory is my world . work . Social Worker Ċ import Ġdagger . h ilt . android . lifecycle . H ilt ViewModel Ċ import Ġkotlinx . coroutines . flow . Mutable State Flow Ċ import Ġkotlinx . coroutines . flow . State Flow Ċ import Ġkotlinx . coroutines . flow . as State Flow Ċ import Ġkotlinx . coroutines . launch Ċ import Ġjavax . inject . Inject Ċ Ċ abstract Ġclass ĠOther Profile ViewModel Ġ: ĠViewModel () Ġ{ ĊĠĠĠ Ġprivate Ġval Ġmutable Network State Ġ= ĠMutable State Flow < Network Status >( Network Status . Unavailable ) ĊĠĠĠ Ġval Ġnetwork State : ĠState Flow < Network Status > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġmutable Network State . as State Flow () ĊĊĠĠĠ Ġfun Ġset Network State ( state : ĠNetwork Status ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmutable Network State . value Ġ= Ġstate ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprotected Ġval Ġmutable Fetch Profile State Ġ= ĠMutable State Flow < Fetch State < UserDetails >>( Fetch State . Initial ) ĊĠĠĠ Ġval Ġfetch Profile Details State : ĠLive Data < Fetch State < UserDetails >> Ġ= ĊĠĠĠĠĠĠĠ Ġmutable Fetch Profile State . as LiveData ( viewModel Scope . coroutine Context ) ĊĊĠĠĠ Ġprotected Ġval Ġmutable Fetch St ories State Ġ= ĠMutable State Flow < Fetch State < List < Graph Data Info >> >( Fetch State . Initial ) ĊĠĠĠ Ġval Ġfetch St ories State : ĠLive Data < Fetch State < List < Graph Data Info >>> Ġ= ĊĠĠĠĠĠĠĠ Ġmutable Fetch St ories State . as LiveData ( viewModel Scope . coroutine Context ) Ċ } Ċ Ċ @ H ilt ViewModel Ċ class ĠOther Profile ViewModel Impl Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġsaved State Handle : ĠSaved State Handle , ĊĠĠĠ Ġprivate Ġval Ġuser Repository : ĠUser Repository Impl , ĊĠĠĠ Ġprivate Ġval Ġgraph Repository : ĠGraph Repository Impl , ĊĠĠĠ Ġprivate Ġval Ġwork Manager : ĠWork Manager Ċ ) Ġ: ĠOther Profile ViewModel () Ġ{ ĊĊĠĠĠ Ġval Ġusername : ĠString Ġget () Ġ= Ġsaved State Handle [" username "] Ġ?: Ġ"" ĊĠĠĠ Ġvar Ġuser Details : ĠUser Details ? Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġprivate Ġset ĊĠĠĠ Ġvar Ġstories : ĠList < Graph Data Info >? Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġprivate Ġset ĊĠĠĠ Ġvar Ġfollowing : ĠBoolean ? Ġ= Ġnull ĊĊĠĠĠ Ġfun Ġfetch UserDetails Remote () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmutable Fetch Profile State . value Ġ= ĠFetch State . Loading ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġuser Repository . getUser Details ( username ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( result . is Success ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġuser Details Ġ= Ġresult . get OrNull () !! ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmutable Fetch Profile State . value Ġ= ĠFetch State . Success ( result . get OrNull () !! ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmutable Fetch Profile State . value Ġ= ĠFetch State . Error ( result . exception OrNull ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġfetch St ories Remote () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmutable Fetch St ories State . value Ġ= ĠFetch State . Loading ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġgraph Repository . get Graph DataList By Username Remote ( username ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( result . is Success ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstories Ġ= Ġresult . get OrNull () !! ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( result . get OrNull () !!. isNotEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmutable Fetch St ories State . value Ġ= ĠFetch State . Success ( result . get OrNull () !! ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmutable Fetch St ories State . value Ġ= ĠFetch State . NotFound ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmutable Fetch St ories State . value Ġ= ĠFetch State . Error ( result . exception OrNull ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġfollow The User () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSocial Worker . run ( work Manager , ĠSocial Worker . Companion . Social Worker Mode . FOLLOW , Ġusername Ġ= Ġusername ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġdont Follow The User () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSocial Worker . run ( work Manager , ĠSocial Worker . Companion . Social Worker Mode . D ONT _ FOLLOW , Ġusername Ġ= Ġusername ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }