package Ġle od en ault . sync ed . server selector Ċ Ċ import Ġandroidx . compose . runtime . mutable State Of Ċ import Ġandroidx . compose . runtime . getValue Ċ import Ġandroidx . compose . runtime . setValue Ċ import Ġdagger . Re usable Ċ import Ġdev . k ord . common . entity . Channel Type Ċ import Ġdev . k ord . core . entity . Guild Ċ import Ġdev . k ord . core . entity . channel . Voice Channel Ċ import Ġkotlinx . coroutines . flow . filter Ċ import Ġkotlinx . coroutines . flow . map Ċ import Ġkotlinx . coroutines . launch Ċ import Ġle od en ault . sync ed . compose . collect Over Time Ċ import Ġle od en ault . sync ed . compose . flow Collection State Of Ċ import Ġle od en ault . sync ed . coroutines . Coroutine Scopes Ċ import Ġle od en ault . sync ed . discord . Connected Client Ċ import Ġle od en ault . sync ed . discord navigation . Discord Navigator Ċ import Ġle od en ault . sync ed . settings . Settings Manager Ċ import Ġle od en ault . sync ed . util . Mutable Data Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠServer Selector ViewModel Ġprivate Ġconstructor ( ĊĠ Ġprivate Ġval Ġchannel ViewModel Factory : ĠChannel ViewModel . Factory , ĊĠ Ġprivate Ġval Ġdiscord Navigator : ĠDiscord Navigator , ĊĠ Ġprivate Ġval Ġconnected Client : ĠConnected Client , ĊĠ Ġprivate Ġval Ġmutable Connected Client : ĠMutable Data < Connected Client ? >, ĊĠ Ġprivate Ġval Ġsettings Manager : ĠSettings Manager Ċ ) Ġ{ ĊĠ Ġval Ġservers Ġ= Ġflow Collection State Of < Server ViewModel >(). also Ġ{ ĊĠĠĠ Ġit . collect Over Time ( connected Client . servers . map Ġ{ Ġserver Ġ-> ĊĠĠĠĠĠ ĠServer ViewModel ( server ) Ġ{ Ġon Server Selected ( server ) Ġ} ĊĠĠĠ Ġ}, ĠCor outine Scopes . io Scope ) ĊĠ Ġ} ĊĠ Ġval Ġchannels Ġ= Ġflow Collection State Of < Channel ViewModel >() ĊĠ Ġvar Ġis Logging Out Ġby Ġmutable State Of ( false ) ĊĠĠĠ Ġprivate Ġset ĊĊĠ Ġprivate Ġfun Ġon Server Selected ( server : ĠGuild ) Ġ{ ĊĠĠĠ Ġval Ġchannel Flow Ġ= ĊĠĠĠĠĠ Ġserver . channels . filter Ġ{ Ġit . type Ġ== ĠChannel Type . Guild Voice Ġ}. map Ġ{ Ġit Ġas ĠVoice Channel Ġ} ĊĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġchannel ViewModel Factory . create ( it ) Ġ} ĊĠĠĠ Ġchannels . collect Over Time ( channel Flow , ĠCor outine Scopes . io Scope ) ĊĠ Ġ} ĊĊĠ Ġfun Ġon Logout Click () Ġ{ ĊĠĠĠ Ġis Logging Out Ġ= Ġtrue ĊĠĠĠ ĠCor outine Scopes . io Scope . launch Ġ{ ĊĠĠĠĠĠ Ġval Ġdisconnected Client Ġ= Ġconnected Client . disconnect () ĊĠĠĠĠĠ Ġmutable Connected Client . value Ġ= Ġnull ĊĠĠĠĠĠ Ġsettings Manager . commit ( settings Manager . fetch (). to Builder (). clear Bot Token (). build ()) ĊĠĠĠĠĠ Ġdiscord Navigator . navigate To Bot Access ( disconnected Client ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Re usable ĊĠ Ġclass ĠFactory Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġchannel ViewModel Factory : ĠChannel ViewModel . Factory , ĊĠĠĠ Ġprivate Ġval Ġmutable Connected Client : ĠMutable Data < Connected Client ? >, ĊĠĠĠ Ġprivate Ġval Ġsettings Manager : ĠSettings Manager ĊĠ Ġ) Ġ{ ĊĠĠĠ Ġfun Ġcreate ( connected Client : ĠConnected Client , Ġdiscord Navigator : ĠDiscord Navigator ) Ġ= ĊĠĠĠĠĠ ĠServer Selector ViewModel ( ĊĠĠĠĠĠĠĠ Ġchannel ViewModel Factory , ĊĠĠĠĠĠĠĠ Ġdiscord Navigator , ĊĠĠĠĠĠĠĠ Ġconnected Client , ĊĠĠĠĠĠĠĠ Ġmutable Connected Client , ĊĠĠĠĠĠĠĠ Ġsettings Manager ĊĠĠĠĠĠ Ġ) ĊĠ Ġ} Ċ }