Skip to content

Commit a6dec62

Browse files
authored
Merge pull request #131 from meteorrn/dev
Release 2.6.0
2 parents cb96f79 + 067c3f9 commit a6dec62

File tree

10 files changed

+41
-13
lines changed

10 files changed

+41
-13
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,3 @@ node_modules
3030
.vscode
3131
.idea
3232
.DS_Store
33-

companion-packages/meteorrn-local/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ const Local = {
9696

9797
LiveCol.find({}).observe({
9898
added: async (doc) => {
99-
LocalCol._collection.upsert(doc);
99+
LocalCol.insert(doc);
100100
storeLocalCol();
101101
},
102-
changed: async (doc) => {
103-
LocalCol._collection.upsert(doc);
102+
changed: async (changes, oldDoc) => {
103+
delete changes._id;
104+
LocalCol.update(oldDoc._id, { $set: changes });
104105
storeLocalCol();
105106
},
106107
});

companion-packages/meteorrn-local/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@meteorrn/local",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Store data locally",
55
"main": "index.js",
66
"scripts": {

docs/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Connect to the Meteor Server
2323
- autoReconnect **boolean** [true] whether to try to reconnect to the server when the socket connection closes, unless the closing was initiated by a call to the disconnect method.
2424
- reconnectInterval **number** [10000] the interval in ms between reconnection attempts.
2525
- AsyncStorage **object** your preferred AsyncStorage. Defaults to `'@react-native-async-storage/async-storage'` as a peer dependency.
26+
- reachabilityUrl **string** ["https://clients3.google.com/generate_204"] server to check internet reachability, used by NetInfo. If not provided, NetInfos default url will be used, which currently is `'https://clients3.google.com/generate_204'`
2627

2728
### `Meteor.disconnect()`
2829

lib/ddp.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EventEmitter } from 'events';
1+
import EventEmitter from 'eventemitter3';
22
import Queue from './queue';
33
import Socket from './socket';
44
import { uniqueId } from './utils';
@@ -115,6 +115,7 @@ export default class DDP extends EventEmitter {
115115
this.socket.on('message:in', (message) => {
116116
if (message.msg === 'connected') {
117117
this.status = 'connected';
118+
this._lastSessionId = message.session;
118119
this.messageQueue.process();
119120
this.emit('connected');
120121
} else if (message.msg === 'ping') {

lib/socket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EventEmitter } from 'events';
1+
import EventEmitter from 'eventemitter3';
22
import EJSON from 'ejson';
33
import './mongo-id'; // Register mongo object ids */
44

package-lock.json

Lines changed: 11 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@meteorrn/core",
3-
"version": "2.5.1",
3+
"version": "2.6.0",
44
"description": "Full Meteor Client for React Native",
55
"main": "src/index.js",
66
"repository": {
@@ -28,7 +28,8 @@
2828
"homepage": "https://github.com/TheRealNate/meteor-react-native#readme",
2929
"dependencies": {
3030
"@meteorrn/minimongo": "1.0.1",
31-
"ejson": "2.2.3"
31+
"ejson": "2.2.3",
32+
"eventemitter3": "^5.0.1"
3233
},
3334
"devDependencies": {
3435
"@babel/core": "7.19.6",

src/Meteor.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,16 @@ const Meteor = {
113113

114114
try {
115115
const NetInfo = require('@react-native-community/netinfo').default;
116+
117+
if (options.reachabilityUrl) {
118+
NetInfo.configure({
119+
reachabilityUrl: options.reachabilityUrl,
120+
useNativeReachability: true,
121+
});
122+
}
123+
116124
// Reconnect if we lose internet
125+
117126
NetInfo.addEventListener(
118127
({ type, isConnected, isInternetReachable, isWifiEnabled }) => {
119128
if (isConnected && Data.ddp.autoReconnect) {
@@ -160,6 +169,13 @@ const Meteor = {
160169
console.info('Disconnected from DDP server.');
161170
}
162171

172+
// Mark subscriptions as ready=false
173+
for (var i in Data.subscriptions) {
174+
const sub = Data.subscriptions[i];
175+
sub.ready = false;
176+
sub.readyDeps.changed();
177+
}
178+
163179
if (!Data.ddp.autoReconnect) return;
164180

165181
if (!lastDisconnect || new Date() - lastDisconnect > 3000) {

src/user/User.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ const User = {
177177
}
178178
this._loadInitialUser();
179179
}, time + 100);
180+
} else if (err?.error === 403) {
181+
User.logout();
180182
} else {
181183
User._handleLoginCallback(err, result);
182184
}

0 commit comments

Comments
 (0)