Commit Graph

77 Commits

Author SHA1 Message Date
Davide De Rosa 9984c56084 Drop unnecessary async from migration code
Providers are not fetched at migration time, they only are after
opening a profile (marked non-ready until then).

Still retain Task for migration to be executed asynchronously.
2022-05-05 11:04:12 +02:00
Davide De Rosa 57f7b15aa2 Reuse base fetch request building code
Set .predicate first for consistency.
2022-05-05 10:58:25 +02:00
Davide De Rosa ae6b5c50d9 Fix duplicated infrastructures/servers
Leftover from some refactoring, was not deleting older
infrastructures before adding a new one.
2022-05-05 10:52:32 +02:00
Davide De Rosa cca2dca047 Export providers database in beta 2022-05-05 09:46:12 +02:00
Davide De Rosa 19886c2314 Drop extra comments 2022-05-04 23:57:45 +02:00
Davide De Rosa bafac12be4 Retain in beta profiles created in production
Drop filter, ability to create profiles in the first place implies
eligibility.
2022-05-04 23:15:12 +02:00
Davide De Rosa c2676cbdf6 Attempt beta release 2022-05-04 19:03:22 +02:00
Davide De Rosa 40a3c67b1c Observe updates AFTER setting active profile
App disconnects VPN on launch otherwise, because active
profile is still nil. Where was the regression introduced?

Also .dropFirst() to skip initial values, but keep in mind that
if VPN is connected and active profile was not properly persisted,
the app will show the VPN as disabled.
2022-05-04 10:34:28 +02:00
Davide De Rosa 56540485cf Fix variable in activeProfileId log message 2022-05-04 09:50:32 +02:00
Davide De Rosa 7ec6ccda6c Improve logic of setting duplicate as current
Back currentProfileId with an internal variable that allows for
more control over navigation.

Can drop pendingProfiles hack.
2022-05-04 09:50:32 +02:00
Davide De Rosa b68fb21652 Fix duplicate on iOS 14
Wrong braces in 4cb18965c9.
2022-05-04 09:12:06 +02:00
Davide De Rosa 4cb18965c9 Set duplicate as current inside ProfileManager
When setting duplicate as current, batch save original profile and
duplicate in a single call via profilesToSave. This is to avoid a
double call to willUpdateProfiles() when saving Core Data context.

In order to set current profile to one that has not been persisted
yet (the duplicate), we need to resort to a pendingProfiles map
where to look the duplicate up when setting currentProfileId.

Either way, iOS 14 cannot handle updating a "hot" change in a
presented NavigationLink. Changing currentProfileId binding while
in ProfileView messes up navigation completely (multiple push and
pop events). Avoid.
2022-05-03 18:35:19 +02:00
Davide De Rosa 943bce5515 Bind navigation to ProfileManager directly
- Do the profile loading inside the model

- Allow setting current profile to a transient profile

- Check .placeholder before saving current profile

XXX: avoid loading active profile on iPad portrait.
2022-05-03 18:35:17 +02:00
Davide De Rosa 7036ca5f41 Fix handling of non-ready profiles
- Omit title while isLoading, to not show former profile name

- Animate on isLoading
2022-05-03 15:54:19 +02:00
Davide De Rosa 93abaf538b Simplify redundant parts of ProfileManager
- Drop overthought activeHeader

- Drop willUpdateCurrentProfile, use observable

- Drop willUpdateActiveId, observe value publisher
2022-05-03 14:36:55 +02:00
Davide De Rosa 20be153b1a Only tweak .isLoading if profile is not ready
Result is sync and immediate otherwise.
2022-05-02 11:17:51 +02:00
Davide De Rosa 7eec20c75b Fix VPN status not restored on app launch
Notifications deemed not relevant because currentBundleIdentifier
not set unless connect/reinstate.

Assume initial relevant identifier to be the first notified.

See 7ba41a0e73
2022-05-01 22:50:40 +02:00
Davide De Rosa 87f2ebfd9e Attempt beta release 2022-05-01 20:44:17 +02:00
Davide De Rosa acbc1980f9 Ignore non-existing active profile 2022-05-01 20:40:20 +02:00
Davide De Rosa 171c1e1dd4 Omit wrapping Section on Mac 2022-05-01 19:30:56 +02:00
Davide De Rosa cfc0d4f572 Restore active profile on top
Flashing on activation was caused by VPNManager.disable() in
ProfileView+VPN, because by setting lastError to nil it would
notify a change to ProfileRow (via VPNStateView) during the
profile row activation animation. That caused the flicker.

Instead, disable VPN first, then start the animation.

Anyway, avoid clearing a nil lastError.
2022-05-01 19:19:43 +02:00
Davide De Rosa edc7cdf045 Merge List into OrganizerView
- Restore wrapping Section as it seems to fix multitasking

- Hide profiles section if empty
2022-05-01 19:19:31 +02:00
Davide De Rosa 8003b4a92d Observe currentProfile in ProfileView
ProfileView is not interested in changes in other profiles
notified by ProfileManager. Set isLoading inside
ObservableObject for observable to be self-contained.

Loses observation of profile deletion, but dismiss on removal is
actually handled by OrganizerView, not ProfileView.

Also drop unused presentationMode.
2022-05-01 19:14:34 +02:00
Davide De Rosa 7ba41a0e73 Skip irrelevant notifications for VPN protocol
Based on tunnel bundle identifier in notification.
2022-04-29 15:26:10 +02:00
Davide De Rosa 17198e53eb Fix cannot duplicate same profile more than once 2022-04-29 00:40:56 +02:00
Davide De Rosa 1afd227f02 Do not update current profile on activation 2022-04-28 22:36:31 +02:00
Davide De Rosa 2c2e794b00 Revert async loadCurrentProfile()
Make action sync, but internally async (makeProfileReady). If not
doing so, UI on launch will not be able to show active profile
immediately. WelcomeView would appear for a moment.

Observe isReloadingCurrentProfile.

See 2b1efb8fec
2022-04-28 19:00:36 +02:00
Davide De Rosa 1ef2b8c7a7 Set activeProfileId immediately
Otherwise on app launch, active profile is rendered in 2 steps.
2022-04-28 17:56:28 +02:00
Davide De Rosa 56fa161e92 Save current profile one way
Skip updating currentProfile.value when intentionally saving
current profile.
2022-04-28 17:56:28 +02:00
Davide De Rosa 2b1efb8fec Make load*Profile() async
- Handle Task in consumers

- Drop makeReady, always make loaded profile ready

- Rename misleading loadProfile() to profileEx()
2022-04-27 17:13:03 +02:00
Davide De Rosa 02b2e3194e Add duplicate to profile menu
Contextually switch current profile to duplicate.
2022-04-27 16:59:33 +02:00
Davide De Rosa 49a1f1b55c Address VPN toggle losing sync with internal state
- Update TunnelKit

- Receive TunnelKit notifications on main queue

- Bind VPN toggle to VPNManager directly (implicit animations)

- Update state on VPN didFail

- Set isEnabled = false after uninstalling VPN (not notified)
2022-04-27 15:53:31 +02:00
Davide De Rosa 03fdab4833 Duplicate profile from context menu 2022-04-26 22:39:47 +02:00
Davide De Rosa e10f33717d Test update/delete on merge provider index 2022-04-26 18:56:55 +02:00
Davide De Rosa 259a7e18ca Fix old provider server query parameter
serverId was renamed to apiId.
2022-04-26 18:49:34 +02:00
Davide De Rosa ccde6a30cf Fix issues with VPN toggle
- Move rate limit to UI only

- Keep caption constant to "Enabled"
2022-04-25 23:12:45 +02:00
Davide De Rosa 92b9c4cd9a Skip setting data count if unavailable 2022-04-25 22:59:20 +02:00
Davide De Rosa 10537c5a29 Fix active profile not always cleared on deletion
Was only cleared if deleted profile was current profile.
2022-04-23 10:25:31 +02:00
Davide De Rosa 8f4e4bc7c5 Skip redundant updates of current profile 2022-04-23 10:25:31 +02:00
Davide De Rosa 2432f0d97a Rewrite ProfileView as a view of currentProfile
Do not load profile in View, instead:

- Load active profile on app launch

- Load selected profile on organizer selection
2022-04-23 10:25:31 +02:00
Davide De Rosa 8838e9d130 Strip a few unnecessary publishers
- Drop unused AppManager from OrganizerView

- Do not notify ProfileManager subscribers on activeProfileId

Saved active profile is already notified by:

- Core Data
- AppManager
2022-04-23 10:25:31 +02:00
Davide De Rosa 322bdf2993 Serialize active profile immediately
Otherwise:

- Switch from former active profile A to B
- Connect to now active profile B
- Kill app
- Reopen app
- App shows connected to profile A

Because active profile was not saved immediately on switch.

Unnecessary now to also save it on background persist().
2022-04-22 10:05:28 +02:00
Davide De Rosa 18e9f7cbb5 Clear profile selection if current profile removed
Do it before ForEach rearranges NavigationLink elements, because
it may trigger undesired navigation to a deleted profile.

Restore related assertion.
2022-04-19 21:19:43 +02:00
Davide De Rosa d2c4298f2d Share same build number in API 2022-04-19 15:56:41 +02:00
Davide De Rosa f1aa192c9c Make App/Core iOS/Catalyst only
- Drop macOS target from Package.swift

- Drop @available attributes
    - UI idiom
    - Intents API
    - Swipe actions in ProviderLocationView

- Review os(iOS)
    - DebugLog, append idiom to tell Mac from iPad

- Drop redundant canImport
2022-04-19 15:56:41 +02:00
Davide De Rosa a6c7305528 Hack around missing .ethernet on Catalyst
Enum seems to be mapped correctly. Make sure matching works on
real device though.

Also noticed that @available on iOS implies availability on
Catalyst as well, making it ineffective e.g. in this case, where
mobile and ethernet network matching should be only available on
iOS and macOS respectively.
2022-04-19 15:56:41 +02:00
Davide De Rosa 5d85699ce4 Delete profile from Organizer
Swipe to delete. Address a couple things on iPad though:

1. Also check provider availability before showing view

fatalError hit on iPad when navigating from a ready provider
profile to a non-ready one. Similar to when navigating between
different VPN protocols.

2. Suppress assertion on deleted profile

Deleting current profile via swipe seems to re-render a new
NavigationLink with the deleted profile, which results in
loading a deleted profile and hitting the assertion. Not sure if
this is a programming error or a glitch in ForEach.
2022-04-19 08:38:10 +02:00
Davide De Rosa f5c87d43c2 Better observe updates explicitly after init 2022-04-18 19:51:07 +02:00
Davide De Rosa 5cafd9794d Review a bit about duplicates handling
- Read profile(withId:) without fetcher

- Refine redundant log about duplicated profiles
2022-04-16 11:27:31 +02:00
Davide De Rosa 0db3e36bf4 Make network settings consistent
- Group DNS "Enabled" and protocol into configuration

- Make DNS servers / search domains optional

- Make proxy bypass domains optional

Also refine a comment about future on-demand.
2022-04-14 07:43:44 +02:00