SwiftUI @AutoOpen and Realm.Configuration question

Hi folks,

In my app I’m trying to use ‘@AutoOpen’ because I want to offer offline access to data after an initial sync. I’m specifically choosing ‘@AutoOpen’ because I don’t want to block the user on syncing first if they are offline, I want this behavior to try to open, but time out and use offline mode if the user can’t login again.

However, I’m not sure how to use the Realm.Configuration in each of these scenarios and get the data in both cases.

Here’s what I have working:

        if let user = app.currentUser {
            config = user.configuration(partitionValue: "")
        }
... then later on...
  .environment(\.realmConfiguration, config)

When my app is online, my data from Atlas syncs up great, no problem.
What should I do if my app is offline? I tried using .defaultConfiguration instead, but this opens up an empty Realm instance with no data in it. I want to still access my existing data from before. Please advise?

Ok, I can perhaps answer my own question…
If I understand correctly, after the first time the realm sync succeeds, if I launch the app again in offline mode (literally airplane mode) the AutoOpen will return the user’s realm instance in case .open(let realm): ... and as long as I inject that realm instance into the environment of the next child view i.e. ListView(items).environment(\.realm, realm), it is the intended and correct realm and I see the previously synced data.

Huzzah! At least I think huzzah…please comment if I have any of that wrong at all.