Skip to content

Proxy: fix proxy settings not reactively applied in UnauthorizedAccount#180

Open
mvsrcdst wants to merge 1 commit into
Swiftgram:masterfrom
mvsrcdst:fix/proxy-unauth-reactivity
Open

Proxy: fix proxy settings not reactively applied in UnauthorizedAccount#180
mvsrcdst wants to merge 1 commit into
Swiftgram:masterfrom
mvsrcdst:fix/proxy-unauth-reactivity

Conversation

@mvsrcdst

@mvsrcdst mvsrcdst commented Jul 16, 2026

Copy link
Copy Markdown

Problem


If user changes/switch proxy settings mid-login before authorization completes, the change isn't picked up and the app keeps using the proxy config it had at login start. Only workaround: restart the app.

Root cause: Account (post-login) already has a reactive subscription to SharedDataKeys.proxySettings that pushes proxy changes into the live MTProto network environment. UnauthorizedAccount (pre-login) had no equivalent, proxy settings were read once at init and effectively frozen for the rest of the login flow.

Fix


Add the same reactive subscription to UnauthorizedAccount that Account already has:

  • subscribe to SharedDataKeys.proxySettings, distinctUntilChanged
  • on change, compare current vs updated MTSocksProxySettings
  • if different, drop connection status and push the updated settings into network.context's API env

Tracked with MetaDisposable, disposed in deinit.

Impact


Switching/changing SOCKS5 proxy mid-login now takes effect immediately, no app restart needed.

Note


Part of tracking issue: #182

Testing


  • Tested on iOS Simulator 18.6/26.5
  • Start login flow, open proxy connection settings, set proxy, confirm connection recovers without restart app

@mvsrcdst mvsrcdst marked this pull request as ready for review July 16, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant