Skip to content

Commit 192bfa5

Browse files
authored
RSTUDIO-540: Fix connect to server (#1666)
* Updating base url * Avoiding initial subscriptions * Using Realm.open to ensure schema gets downloaded before onRealmLoaded gets called * Adding a vNext entry in the changelog * Adding an entry in the changelog
1 parent 844993d commit 192bfa5

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
# Changelog
1+
## vNext (TBD)
2+
3+
### Enhancements
4+
* None
5+
6+
### Fixed
7+
* Fixed connecting to the server and opening synced Realms ([#1665](https://github.com/realm/realm-studio/issues/1665), since v15.0.0)
8+
9+
### Internals
10+
* None
211

312
## 15.2.0 (2024-06-12)
413

src/ui/ConnectToServer/ConnectToServer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const ConnectToServer = ({
9393
type="url"
9494
name="serverUrl"
9595
id="serverUrl"
96-
placeholder="https://realm.mongodb.com"
96+
placeholder="https://services.cloud.mongodb.com"
9797
value={url}
9898
onChange={onUrlChanged}
9999
/>

src/ui/ConnectToServer/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import {
3535

3636
import { ConnectToServer } from './ConnectToServer';
3737

38-
const DEFAULT_BASE_URL = 'https://realm.mongodb.com';
38+
const DEFAULT_BASE_URL = 'https://services.cloud.mongodb.com';
39+
const LEGACY_BASE_URL = 'https://realm.mongodb.com';
3940

4041
/*
4142
const MISSING_PARAMS_MESSAGE =
@@ -83,7 +84,7 @@ class ConnectToServerContainer extends React.Component<
8384
const url = this.props.url || this.getLatestUrl();
8485
this.setState({
8586
// Use an empty input instead of filling in the default URL
86-
url: url === DEFAULT_BASE_URL ? '' : url,
87+
url: url === DEFAULT_BASE_URL || url === LEGACY_BASE_URL ? '' : url,
8788
appId: this.getLatestAppId(),
8889
});
8990
// this.restoreCredentials(url);
@@ -114,9 +115,8 @@ class ConnectToServerContainer extends React.Component<
114115
const { appId, url } = this.state;
115116
// Use SDK default (passing undefined) on an empty string.
116117
const baseUrl = url || DEFAULT_BASE_URL;
117-
// Clear test state to invalidate the shared App cache as a work around for
118+
// TODO: Clear test state to invalidate the shared App cache as a work around for
118119
// https://github.com/realm/realm-js/issues/6276
119-
(Realm.App as any)._clearAppCache();
120120
const app = new App({ id: appId, baseUrl });
121121
const serializedCredentials = this.serializeCredentials();
122122
const credentials = hydrateCredentials(serializedCredentials);

src/ui/reusable/RealmLoadingComponent/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,12 @@ export abstract class RealmLoadingComponent<
156156
});
157157
const credentials = hydrateCredentials(realm.credentials);
158158
const user = await app.logIn(credentials);
159-
return new Realm({
159+
return Realm.open({
160160
encryptionKey: realm.encryptionKey,
161161
sync: {
162162
user,
163163
flexible: true,
164+
/*
164165
initialSubscriptions: {
165166
update(subs, realm) {
166167
for (const schema of realm.schema) {
@@ -169,6 +170,7 @@ export abstract class RealmLoadingComponent<
169170
}
170171
},
171172
},
173+
*/
172174
},
173175
schema,
174176
schemaVersion,

0 commit comments

Comments
 (0)