@ethora/chat-component-rn 26.5.2 → 26.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -3
- package/README.md +1 -1
- package/lib/commonjs/networking/api-requests/push.api.js +1 -1
- package/lib/commonjs/networking/api-requests/push.api.js.map +1 -1
- package/lib/commonjs/services/pushSubscriptionService.js +1 -21
- package/lib/commonjs/services/pushSubscriptionService.js.map +1 -1
- package/lib/module/networking/api-requests/push.api.js +1 -1
- package/lib/module/networking/api-requests/push.api.js.map +1 -1
- package/lib/module/services/pushSubscriptionService.js +1 -21
- package/lib/module/services/pushSubscriptionService.js.map +1 -1
- package/lib/typescript/networking/api-requests/push.api.d.ts.map +1 -1
- package/lib/typescript/services/pushSubscriptionService.d.ts.map +1 -1
- package/package.json +31 -7
- package/src/networking/api-requests/push.api.ts +1 -1
- package/src/services/pushSubscriptionService.ts +1 -24
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
All notable changes to `@ethora/chat-component-rn` are listed here.
|
|
4
4
|
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this project doesn't follow strict semver yet — version corresponds to the `package.json` field.
|
|
5
5
|
|
|
6
|
-
## [
|
|
6
|
+
## [26.5.3]
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
### Changed (breaking on paper, transparent in practice for Expo apps)
|
|
9
|
+
|
|
10
|
+
- **Moved Expo packages from `dependencies` to `peerDependencies`** with `peerDependenciesMeta.<name>.optional: true`. Affected: `expo-av`, `expo-clipboard`, `expo-document-picker`, `expo-image-manipulator`, `expo-image-picker`, `expo-media-library`. Reason: when these sat in `dependencies`, npm sometimes nested them under `node_modules/@ethora/chat-component-rn/node_modules/` (version dedup with the consumer's Expo SDK), and Expo's `app.json` plugin resolver — which only scans the project root's `node_modules/` — failed to find them. Consumers running `npx expo prebuild` got a `PluginError: Failed to resolve plugin for module "expo-image-picker"`. Moving them to peers makes consumers install once at top level (typically `npx expo install expo-image-picker expo-document-picker ...`), which is what every other RN-with-native lib does. Bonus: the SDK tarball drops 6 transitive Expo packages.
|
|
11
|
+
|
|
12
|
+
> **Upgrade note**: In your app, run `npx expo install expo-av expo-clipboard expo-document-picker expo-image-manipulator expo-image-picker expo-media-library` once. Or only the ones you actually use — they're all optional, runtime imports fail loudly with the same `Cannot find module 'expo-av'` you'd see today.
|
|
13
|
+
|
|
14
|
+
## [26.5.2]
|
|
15
|
+
|
|
16
|
+
Integration-hardening round: closes a batch of runtime issues and a structural "ships raw TS" problem that surfaced during a real-world consumer integration.
|
|
9
17
|
|
|
10
18
|
### Added
|
|
11
19
|
|
|
@@ -23,7 +31,7 @@ The customer hit a batch of runtime issues and a structural "ships raw TS" probl
|
|
|
23
31
|
#### Runtime crashes / red screens
|
|
24
32
|
|
|
25
33
|
- **`addRoomViaApi` crashed on the new-arch path** — the function was imported in `useGetNewArchRoom`, `AddMembersModal`, `UserProfileModal`, and `NewChatModal` but never existed in `roomsSlice`. Added as a `createAsyncThunk` that dispatches a new `addRoomFromApi` reducer. Consumers can now set `newArch: true` instead of the previous `newArch: false` workaround.
|
|
26
|
-
- **Unhandled promise rejections** from `getRoomsStanza` / `getHistoryStanza` `.then()` chains with no `.catch()` — these surfaced as red-screen errors that
|
|
34
|
+
- **Unhandled promise rejections** from `getRoomsStanza` / `getHistoryStanza` `.then()` chains with no `.catch()` — these surfaced as red-screen errors that integrators had to suppress with `LogBox.ignoreLogs`. Added `.catch` handlers in `ChatWrapper` (three call sites) and `ThreadWrapper`.
|
|
27
35
|
- **`onGetMembers` wiped REST-loaded members** by dispatching an empty `roomMembers: []` whenever a quiet room's IQ stanza arrived without activities. Now early-returns on empty activities and merges with existing per-jid members instead of replacing.
|
|
28
36
|
|
|
29
37
|
#### Keyboard
|
package/README.md
CHANGED
|
@@ -368,7 +368,7 @@ npm run e2e:ios
|
|
|
368
368
|
npm run e2e:android
|
|
369
369
|
|
|
370
370
|
# Or pass a different profile / room
|
|
371
|
-
scripts/run-e2e.sh ios "
|
|
371
|
+
scripts/run-e2e.sh ios "Sample Profile" "General"
|
|
372
372
|
```
|
|
373
373
|
|
|
374
374
|
The flow targets stable `testID`s wired into the SDK
|
|
@@ -15,7 +15,7 @@ const pushAxios = _axios.default.create({
|
|
|
15
15
|
'Content-Type': 'application/json'
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
async function subscribeToPushNotifications(fcmToken, userJid, projectName = '
|
|
18
|
+
async function subscribeToPushNotifications(fcmToken, userJid, projectName = '') {
|
|
19
19
|
const deviceType = _reactNative.Platform.select({
|
|
20
20
|
ios: 'ios',
|
|
21
21
|
android: 'android',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_axios","_interopRequireDefault","require","_reactNative","_roomStore","e","__esModule","default","PUSH_API_URL","pushAxios","axios","create","baseURL","headers","subscribeToPushNotifications","fcmToken","userJid","projectName","deviceType","Platform","select","ios","android","payload","projectId","registrationToken","jid","console","log","token","store","getState","chatSettingStore","user","response","post","Authorization","data","error"],"sourceRoot":"../../../../src","sources":["networking/api-requests/push.api.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAAwC,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExC,MAAMG,YAAY,GAAG,mCAAmC;AAExD,MAAMC,SAAS,GAAGC,cAAK,CAACC,MAAM,CAAC;EAC7BC,OAAO,EAAEJ,YAAY;EACrBK,OAAO,EAAE;IACP,cAAc,EAAE;EAClB;AACF,CAAC,CAAC;AASK,eAAeC,4BAA4BA,CAChDC,QAAgB,EAChBC,OAAe,EACfC,WAAmB,GAAG,
|
|
1
|
+
{"version":3,"names":["_axios","_interopRequireDefault","require","_reactNative","_roomStore","e","__esModule","default","PUSH_API_URL","pushAxios","axios","create","baseURL","headers","subscribeToPushNotifications","fcmToken","userJid","projectName","deviceType","Platform","select","ios","android","payload","projectId","registrationToken","jid","console","log","token","store","getState","chatSettingStore","user","response","post","Authorization","data","error"],"sourceRoot":"../../../../src","sources":["networking/api-requests/push.api.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAAwC,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExC,MAAMG,YAAY,GAAG,mCAAmC;AAExD,MAAMC,SAAS,GAAGC,cAAK,CAACC,MAAM,CAAC;EAC7BC,OAAO,EAAEJ,YAAY;EACrBK,OAAO,EAAE;IACP,cAAc,EAAE;EAClB;AACF,CAAC,CAAC;AASK,eAAeC,4BAA4BA,CAChDC,QAAgB,EAChBC,OAAe,EACfC,WAAmB,GAAG,EAAE,EACT;EACf,MAAMC,UAAqC,GAAGC,qBAAQ,CAACC,MAAM,CAAC;IAC5DC,GAAG,EAAE,KAAK;IACVC,OAAO,EAAE,SAAS;IAClBf,OAAO,EAAE;EACX,CAAC,CAA8B;EAE/B,MAAMgB,OAAgC,GAAG;IACvCC,SAAS,EAAEP,WAAW;IACtBQ,iBAAiB,EAAEV,QAAQ;IAC3BG,UAAU;IACVQ,GAAG,EAAE,GAAGV,OAAO;EACjB,CAAC;EAEDW,OAAO,CAACC,GAAG,CAAC,SAAS,EAAEL,OAAO,CAAC;EAE/B,IAAI;IACF,MAAMM,KAAK,GAAGC,gBAAK,CAACC,QAAQ,CAAC,CAAC,CAACC,gBAAgB,EAAEC,IAAI,EAAEJ,KAAK,IAAI,EAAE;IAElE,MAAMK,QAAQ,GAAG,MAAMzB,SAAS,CAAC0B,IAAI,CAAC,gBAAgB,EAAEZ,OAAO,EAAE;MAC/DV,OAAO,EAAE;QACPuB,aAAa,EAAE,UAAUP,KAAK;MAChC;IACF,CAAC,CAAC;IACFF,OAAO,CAACC,GAAG,CAAC,+CAA+C,EAAEM,QAAQ,CAACG,IAAI,CAAC;IAC3E,OAAOH,QAAQ,CAACG,IAAI;EACtB,CAAC,CAAC,OAAOC,KAAU,EAAE;IACnBX,OAAO,CAACW,KAAK,CAAC,4CAA4C,EAAEA,KAAK,CAAC;EACpE;AACF","ignoreList":[]}
|
|
@@ -9,10 +9,6 @@ var _push = require("../networking/api-requests/push.api");
|
|
|
9
9
|
var _subscribeToRoomMessages = require("../networking/xmpp/subscribeToRoomMessages.xmpp");
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
const SUBSCRIBED_ROOMS_KEY = 'ethora_subscribed_rooms';
|
|
12
|
-
// Legacy storage key from before the rename. Read on first load and
|
|
13
|
-
// migrated into SUBSCRIBED_ROOMS_KEY so installed apps don't lose
|
|
14
|
-
// their subscriptions. Safe to remove on the next major version.
|
|
15
|
-
const LEGACY_SUBSCRIBED_ROOMS_KEY = 'preshent_subscribed_rooms';
|
|
16
12
|
class PushSubscriptionService {
|
|
17
13
|
subscribedRooms = new Set();
|
|
18
14
|
isPushSubscribed = false;
|
|
@@ -23,20 +19,7 @@ class PushSubscriptionService {
|
|
|
23
19
|
return;
|
|
24
20
|
}
|
|
25
21
|
try {
|
|
26
|
-
|
|
27
|
-
if (!storedRooms) {
|
|
28
|
-
// One-time migration from the legacy key.
|
|
29
|
-
try {
|
|
30
|
-
const legacy = await _asyncStorage.default.getItem(LEGACY_SUBSCRIBED_ROOMS_KEY);
|
|
31
|
-
if (legacy) {
|
|
32
|
-
await _asyncStorage.default.setItem(SUBSCRIBED_ROOMS_KEY, legacy);
|
|
33
|
-
await _asyncStorage.default.removeItem(LEGACY_SUBSCRIBED_ROOMS_KEY);
|
|
34
|
-
storedRooms = legacy;
|
|
35
|
-
}
|
|
36
|
-
} catch (migrationError) {
|
|
37
|
-
console.error('[PushService] Legacy storage-key migration failed (subscriptions on this device may be lost):', migrationError);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
22
|
+
const storedRooms = await _asyncStorage.default.getItem(SUBSCRIBED_ROOMS_KEY);
|
|
40
23
|
if (storedRooms) {
|
|
41
24
|
const roomsArray = JSON.parse(storedRooms);
|
|
42
25
|
this.subscribedRooms = new Set(roomsArray);
|
|
@@ -119,9 +102,6 @@ class PushSubscriptionService {
|
|
|
119
102
|
this.isInitialized = false;
|
|
120
103
|
try {
|
|
121
104
|
await _asyncStorage.default.removeItem(SUBSCRIBED_ROOMS_KEY);
|
|
122
|
-
// Defensive: also clear the legacy key if it somehow survived
|
|
123
|
-
// the migration (e.g. migration failed on first load).
|
|
124
|
-
await _asyncStorage.default.removeItem(LEGACY_SUBSCRIBED_ROOMS_KEY);
|
|
125
105
|
console.log('[PushService] Subscribed rooms cleared from storage');
|
|
126
106
|
} catch (error) {
|
|
127
107
|
console.error('[PushService] Failed to clear subscribed rooms from storage:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_asyncStorage","_interopRequireDefault","require","_push","_subscribeToRoomMessages","e","__esModule","default","SUBSCRIBED_ROOMS_KEY","
|
|
1
|
+
{"version":3,"names":["_asyncStorage","_interopRequireDefault","require","_push","_subscribeToRoomMessages","e","__esModule","default","SUBSCRIBED_ROOMS_KEY","PushSubscriptionService","subscribedRooms","Set","isPushSubscribed","lastSubscriptionKey","isInitialized","loadSubscribedRoomsFromStorage","storedRooms","AsyncStorage","getItem","roomsArray","JSON","parse","error","console","saveSubscribedRoomsToStorage","Array","from","setItem","stringify","subscribeToPush","fcmToken","user","projectName","walletAddress","defaultWallet","subscriptionKey","log","userJid","xmppUsername","Error","subscribeToPushNotifications","subscribeToRoom","client","roomJID","userNick","has","result","subscribeToRoomMessages","add","subscribeToRooms","roomJIDs","successful","failed","Promise","resolve","setTimeout","reset","clear","removeItem","isRoomSubscribed","getSubscribedRooms","exports","pushSubscriptionService"],"sourceRoot":"../../../src","sources":["services/pushSubscriptionService.ts"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AAA0F,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1F,MAAMG,oBAAoB,GAAG,yBAAyB;AAE/C,MAAMC,uBAAuB,CAAC;EAC3BC,eAAe,GAAgB,IAAIC,GAAG,CAAC,CAAC;EACxCC,gBAAgB,GAAY,KAAK;EACjCC,mBAAmB,GAAkB,IAAI;EACzCC,aAAa,GAAY,KAAK;EAEtC,MAAcC,8BAA8BA,CAAA,EAAkB;IAC5D,IAAI,IAAI,CAACD,aAAa,EAAE;MAAC;IAAO;IAEhC,IAAI;MACF,MAAME,WAAW,GAAG,MAAMC,qBAAY,CAACC,OAAO,CAACV,oBAAoB,CAAC;MACpE,IAAIQ,WAAW,EAAE;QACf,MAAMG,UAAU,GAAGC,IAAI,CAACC,KAAK,CAACL,WAAW,CAAa;QACtD,IAAI,CAACN,eAAe,GAAG,IAAIC,GAAG,CAACQ,UAAU,CAAC;MAC5C;MACA,IAAI,CAACL,aAAa,GAAG,IAAI;IAC3B,CAAC,CAAC,OAAOQ,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,6DAA6D,EAAEA,KAAK,CAAC;IACrF;EACF;EAEA,MAAcE,4BAA4BA,CAAA,EAAkB;IAC1D,IAAI;MACF,MAAML,UAAU,GAAGM,KAAK,CAACC,IAAI,CAAC,IAAI,CAAChB,eAAe,CAAC;MACnD,MAAMO,qBAAY,CAACU,OAAO,CAACnB,oBAAoB,EAAEY,IAAI,CAACQ,SAAS,CAACT,UAAU,CAAC,CAAC;IAC9E,CAAC,CAAC,OAA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;IAC/B,IAAI,CAACC,aAAa,GAAG,KAAK;IAE1B,IAAI;MACF,MAAMG,qBAAY,CAACyC,UAAU,CAAClD,oBAAoB,CAAC;MACnDe,OAAO,CAACa,GAAG,CAAC,qDAAqD,CAAC;IACpE,CAAC,CAAC,OAAOd,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,8DAA8D,EAAEA,KAAK,CAAC;IACtF;EACF;EAEAqC,gBAAgBA,CAAChB,OAAe,EAAW;IACzC,OAAO,IAAI,CAACjC,eAAe,CAACmC,GAAG,CAACF,OAAO,CAAC;EAC1C;EAEAiB,kBAAkBA,CAAA,EAAa;IAC7B,OAAOnC,KAAK,CAACC,IAAI,CAAC,IAAI,CAAChB,eAAe,CAAC;EACzC;AACF;AAACmD,OAAA,CAAApD,uBAAA,GAAAA,uBAAA;AAEM,MAAMqD,uBAAuB,GAAAD,OAAA,CAAAC,uBAAA,GAAG,IAAIrD,uBAAuB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -10,7 +10,7 @@ const pushAxios = axios.create({
|
|
|
10
10
|
'Content-Type': 'application/json'
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
export async function subscribeToPushNotifications(fcmToken, userJid, projectName = '
|
|
13
|
+
export async function subscribeToPushNotifications(fcmToken, userJid, projectName = '') {
|
|
14
14
|
const deviceType = Platform.select({
|
|
15
15
|
ios: 'ios',
|
|
16
16
|
android: 'android',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["axios","Platform","store","PUSH_API_URL","pushAxios","create","baseURL","headers","subscribeToPushNotifications","fcmToken","userJid","projectName","deviceType","select","ios","android","default","payload","projectId","registrationToken","jid","console","log","token","getState","chatSettingStore","user","response","post","Authorization","data","error"],"sourceRoot":"../../../../src","sources":["networking/api-requests/push.api.ts"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,KAAK,QAAQ,iBAAiB;AAEvC,MAAMC,YAAY,GAAG,mCAAmC;AAExD,MAAMC,SAAS,GAAGJ,KAAK,CAACK,MAAM,CAAC;EAC7BC,OAAO,EAAEH,YAAY;EACrBI,OAAO,EAAE;IACP,cAAc,EAAE;EAClB;AACF,CAAC,CAAC;AASF,OAAO,eAAeC,4BAA4BA,CAChDC,QAAgB,EAChBC,OAAe,EACfC,WAAmB,GAAG,
|
|
1
|
+
{"version":3,"names":["axios","Platform","store","PUSH_API_URL","pushAxios","create","baseURL","headers","subscribeToPushNotifications","fcmToken","userJid","projectName","deviceType","select","ios","android","default","payload","projectId","registrationToken","jid","console","log","token","getState","chatSettingStore","user","response","post","Authorization","data","error"],"sourceRoot":"../../../../src","sources":["networking/api-requests/push.api.ts"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,KAAK,QAAQ,iBAAiB;AAEvC,MAAMC,YAAY,GAAG,mCAAmC;AAExD,MAAMC,SAAS,GAAGJ,KAAK,CAACK,MAAM,CAAC;EAC7BC,OAAO,EAAEH,YAAY;EACrBI,OAAO,EAAE;IACP,cAAc,EAAE;EAClB;AACF,CAAC,CAAC;AASF,OAAO,eAAeC,4BAA4BA,CAChDC,QAAgB,EAChBC,OAAe,EACfC,WAAmB,GAAG,EAAE,EACT;EACf,MAAMC,UAAqC,GAAGX,QAAQ,CAACY,MAAM,CAAC;IAC5DC,GAAG,EAAE,KAAK;IACVC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE;EACX,CAAC,CAA8B;EAE/B,MAAMC,OAAgC,GAAG;IACvCC,SAAS,EAAEP,WAAW;IACtBQ,iBAAiB,EAAEV,QAAQ;IAC3BG,UAAU;IACVQ,GAAG,EAAE,GAAGV,OAAO;EACjB,CAAC;EAEDW,OAAO,CAACC,GAAG,CAAC,SAAS,EAAEL,OAAO,CAAC;EAE/B,IAAI;IACF,MAAMM,KAAK,GAAGrB,KAAK,CAACsB,QAAQ,CAAC,CAAC,CAACC,gBAAgB,EAAEC,IAAI,EAAEH,KAAK,IAAI,EAAE;IAElE,MAAMI,QAAQ,GAAG,MAAMvB,SAAS,CAACwB,IAAI,CAAC,gBAAgB,EAAEX,OAAO,EAAE;MAC/DV,OAAO,EAAE;QACPsB,aAAa,EAAE,UAAUN,KAAK;MAChC;IACF,CAAC,CAAC;IACFF,OAAO,CAACC,GAAG,CAAC,+CAA+C,EAAEK,QAAQ,CAACG,IAAI,CAAC;IAC3E,OAAOH,QAAQ,CAACG,IAAI;EACtB,CAAC,CAAC,OAAOC,KAAU,EAAE;IACnBV,OAAO,CAACU,KAAK,CAAC,4CAA4C,EAAEA,KAAK,CAAC;EACpE;AACF","ignoreList":[]}
|
|
@@ -4,10 +4,6 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
|
4
4
|
import { subscribeToPushNotifications } from '../networking/api-requests/push.api';
|
|
5
5
|
import { subscribeToRoomMessages } from '../networking/xmpp/subscribeToRoomMessages.xmpp';
|
|
6
6
|
const SUBSCRIBED_ROOMS_KEY = 'ethora_subscribed_rooms';
|
|
7
|
-
// Legacy storage key from before the rename. Read on first load and
|
|
8
|
-
// migrated into SUBSCRIBED_ROOMS_KEY so installed apps don't lose
|
|
9
|
-
// their subscriptions. Safe to remove on the next major version.
|
|
10
|
-
const LEGACY_SUBSCRIBED_ROOMS_KEY = 'preshent_subscribed_rooms';
|
|
11
7
|
export class PushSubscriptionService {
|
|
12
8
|
subscribedRooms = new Set();
|
|
13
9
|
isPushSubscribed = false;
|
|
@@ -18,20 +14,7 @@ export class PushSubscriptionService {
|
|
|
18
14
|
return;
|
|
19
15
|
}
|
|
20
16
|
try {
|
|
21
|
-
|
|
22
|
-
if (!storedRooms) {
|
|
23
|
-
// One-time migration from the legacy key.
|
|
24
|
-
try {
|
|
25
|
-
const legacy = await AsyncStorage.getItem(LEGACY_SUBSCRIBED_ROOMS_KEY);
|
|
26
|
-
if (legacy) {
|
|
27
|
-
await AsyncStorage.setItem(SUBSCRIBED_ROOMS_KEY, legacy);
|
|
28
|
-
await AsyncStorage.removeItem(LEGACY_SUBSCRIBED_ROOMS_KEY);
|
|
29
|
-
storedRooms = legacy;
|
|
30
|
-
}
|
|
31
|
-
} catch (migrationError) {
|
|
32
|
-
console.error('[PushService] Legacy storage-key migration failed (subscriptions on this device may be lost):', migrationError);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
17
|
+
const storedRooms = await AsyncStorage.getItem(SUBSCRIBED_ROOMS_KEY);
|
|
35
18
|
if (storedRooms) {
|
|
36
19
|
const roomsArray = JSON.parse(storedRooms);
|
|
37
20
|
this.subscribedRooms = new Set(roomsArray);
|
|
@@ -114,9 +97,6 @@ export class PushSubscriptionService {
|
|
|
114
97
|
this.isInitialized = false;
|
|
115
98
|
try {
|
|
116
99
|
await AsyncStorage.removeItem(SUBSCRIBED_ROOMS_KEY);
|
|
117
|
-
// Defensive: also clear the legacy key if it somehow survived
|
|
118
|
-
// the migration (e.g. migration failed on first load).
|
|
119
|
-
await AsyncStorage.removeItem(LEGACY_SUBSCRIBED_ROOMS_KEY);
|
|
120
100
|
console.log('[PushService] Subscribed rooms cleared from storage');
|
|
121
101
|
} catch (error) {
|
|
122
102
|
console.error('[PushService] Failed to clear subscribed rooms from storage:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AsyncStorage","subscribeToPushNotifications","subscribeToRoomMessages","SUBSCRIBED_ROOMS_KEY","
|
|
1
|
+
{"version":3,"names":["AsyncStorage","subscribeToPushNotifications","subscribeToRoomMessages","SUBSCRIBED_ROOMS_KEY","PushSubscriptionService","subscribedRooms","Set","isPushSubscribed","lastSubscriptionKey","isInitialized","loadSubscribedRoomsFromStorage","storedRooms","getItem","roomsArray","JSON","parse","error","console","saveSubscribedRoomsToStorage","Array","from","setItem","stringify","subscribeToPush","fcmToken","user","projectName","walletAddress","defaultWallet","subscriptionKey","log","userJid","xmppUsername","Error","subscribeToRoom","client","roomJID","userNick","has","result","add","subscribeToRooms","roomJIDs","successful","failed","Promise","resolve","setTimeout","reset","clear","removeItem","isRoomSubscribed","getSubscribedRooms","pushSubscriptionService"],"sourceRoot":"../../../src","sources":["services/pushSubscriptionService.ts"],"mappings":";;AAEA,OAAOA,YAAY,MAAM,2CAA2C;AACpE,SAASC,4BAA4B,QAAQ,qCAAqC;AAClF,SAASC,uBAAuB,QAAQ,iDAAiD;AAEzF,MAAMC,oBAAoB,GAAG,yBAAyB;AAEtD,OAAO,MAAMC,uBAAuB,CAAC;EAC3BC,eAAe,GAAgB,IAAIC,GAAG,CAAC,CAAC;EACxCC,gBAAgB,GAAY,KAAK;EACjCC,mBAAmB,GAAkB,IAAI;EACzCC,aAAa,GAAY,KAAK;EAEtC,MAAcC,8BAA8BA,CAAA,EAAkB;IAC5D,IAAI,IAAI,CAACD,aAAa,EAAE;MAAC;IAAO;IAEhC,IAAI;MACF,MAAME,WAAW,GAAG,MAAMX,YAAY,CAACY,OAAO,CAACT,oBAAoB,CAAC;MACpE,IAAIQ,WAAW,EAAE;QACf,MAAME,UAAU,GAAGC,IAAI,CAACC,KAAK,CAACJ,WAAW,CAAa;QACtD,IAAI,CAACN,eAAe,GAAG,IAAIC,GAAG,CAACO,UAAU,CAAC;MAC5C;MACA,IAAI,CAACJ,aAAa,GAAG,IAAI;IAC3B,CAAC,CAAC,OAAOO,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,6DAA6D,EAAEA,KAAK,CAAC;IACrF;EACF;EAEA,MAAcE,4BAA4BA,CAAA,EAAkB;IAC1D,IAAI;MACF,MAAML,UAAU,GAAGM,KAAK,CAACC,IAAI,CAAC,IAAI,CAACf,eAAe,CAAC;MACnD,MAAML,YAAY,CAACqB,OAAO,CAAClB,oBAAoB,EAAEW,IAAI,CAACQ,SAAS,CAACT,UAAU,CAAC,CAAC;IAC9E,CAAC,CAAC,OAAOG,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,2DAA2D,EAAEA,KAAK,CAAC;IACnF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AAC/C,oBAAoB,CAAC;MACnDc,OAAO,CAACa,GAAG,CAAC,qDAAqD,CAAC;IACpE,CAAC,CAAC,OAAOd,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,8DAA8D,EAAEA,KAAK,CAAC;IACtF;EACF;EAEAmC,gBAAgBA,CAACf,OAAe,EAAW;IACzC,OAAO,IAAI,CAAC/B,eAAe,CAACiC,GAAG,CAACF,OAAO,CAAC;EAC1C;EAEAgB,kBAAkBA,CAAA,EAAa;IAC7B,OAAOjC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACf,eAAe,CAAC;EACzC;AACF;AAEA,OAAO,MAAMgD,uBAAuB,GAAG,IAAIjD,uBAAuB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.api.d.ts","sourceRoot":"","sources":["../../../../src/networking/api-requests/push.api.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,CAAC;IACtC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,
|
|
1
|
+
{"version":3,"file":"push.api.d.ts","sourceRoot":"","sources":["../../../../src/networking/api-requests/push.api.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,CAAC;IACtC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,MAAW,GACvB,OAAO,CAAC,IAAI,CAAC,CA6Bf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushSubscriptionService.d.ts","sourceRoot":"","sources":["../../../src/services/pushSubscriptionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"pushSubscriptionService.d.ts","sourceRoot":"","sources":["../../../src/services/pushSubscriptionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAOtC,qBAAa,uBAAuB;IAClC,OAAO,CAAC,eAAe,CAA0B;IACjD,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,aAAa,CAAkB;YAEzB,8BAA8B;YAe9B,4BAA4B;IASpC,eAAe,CACnB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC;IAwBV,eAAe,CACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC;IAqBb,gBAAgB,CACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAAE,EAClB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC;IAyBV,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAc5B,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAI1C,kBAAkB,IAAI,MAAM,EAAE;CAG/B;AAED,eAAO,MAAM,uBAAuB,yBAAgC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethora/chat-component-rn",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.5.3",
|
|
4
4
|
"description": "Drop-in XMPP chat component for React Native / Expo. <Chat config={...}/> and you're done.",
|
|
5
5
|
"main": "lib/commonjs/main.js",
|
|
6
6
|
"module": "lib/module/main.js",
|
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@react-native-async-storage/async-storage": ">=1.21.0",
|
|
35
|
+
"expo-av": ">=15.0.0",
|
|
36
|
+
"expo-clipboard": ">=7.0.0",
|
|
37
|
+
"expo-document-picker": ">=13.0.0",
|
|
38
|
+
"expo-image-manipulator": ">=13.0.0",
|
|
39
|
+
"expo-image-picker": ">=16.0.0",
|
|
40
|
+
"expo-media-library": ">=17.0.0",
|
|
35
41
|
"react": ">=18.0.0",
|
|
36
42
|
"react-native": ">=0.73.0",
|
|
37
43
|
"react-native-gesture-handler": ">=2.0.0",
|
|
@@ -54,6 +60,24 @@
|
|
|
54
60
|
},
|
|
55
61
|
"react-native-gesture-handler": {
|
|
56
62
|
"optional": true
|
|
63
|
+
},
|
|
64
|
+
"expo-av": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"expo-clipboard": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"expo-document-picker": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"expo-image-manipulator": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"expo-image-picker": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"expo-media-library": {
|
|
80
|
+
"optional": true
|
|
57
81
|
}
|
|
58
82
|
},
|
|
59
83
|
"scripts": {
|
|
@@ -77,12 +101,6 @@
|
|
|
77
101
|
"@reduxjs/toolkit": "^2.5.0",
|
|
78
102
|
"@xmpp/client": "^0.13.1",
|
|
79
103
|
"axios": "^1.7.9",
|
|
80
|
-
"expo-av": "~16.0.8",
|
|
81
|
-
"expo-clipboard": "~8.0.8",
|
|
82
|
-
"expo-document-picker": "~14.0.0",
|
|
83
|
-
"expo-image-manipulator": "~14.0.0",
|
|
84
|
-
"expo-image-picker": "~17.0.0",
|
|
85
|
-
"expo-media-library": "~18.2.1",
|
|
86
104
|
"js-sha256": "^0.11.0",
|
|
87
105
|
"react-native-keyboard-controller": "^1.18.5",
|
|
88
106
|
"react-native-webview": "^13.16.1",
|
|
@@ -101,7 +119,13 @@
|
|
|
101
119
|
"eslint": "^8.19.0",
|
|
102
120
|
"eslint-config-expo": "~9.2.0",
|
|
103
121
|
"expo": "~54.0.0",
|
|
122
|
+
"expo-av": "~16.0.8",
|
|
104
123
|
"expo-build-properties": "^55.0.14",
|
|
124
|
+
"expo-clipboard": "~8.0.8",
|
|
125
|
+
"expo-document-picker": "~14.0.0",
|
|
126
|
+
"expo-image-manipulator": "~14.0.0",
|
|
127
|
+
"expo-image-picker": "~17.0.0",
|
|
128
|
+
"expo-media-library": "~18.2.1",
|
|
105
129
|
"expo-status-bar": "~3.0.0",
|
|
106
130
|
"jest": "^29.6.3",
|
|
107
131
|
"jest-expo": "~54.0.0",
|
|
@@ -21,7 +21,7 @@ export interface PushSubscriptionPayload {
|
|
|
21
21
|
export async function subscribeToPushNotifications(
|
|
22
22
|
fcmToken: string,
|
|
23
23
|
userJid: string,
|
|
24
|
-
projectName: string = '
|
|
24
|
+
projectName: string = '',
|
|
25
25
|
): Promise<void> {
|
|
26
26
|
const deviceType: 'web' | 'android' | 'ios' = Platform.select({
|
|
27
27
|
ios: 'ios',
|
|
@@ -5,10 +5,6 @@ import { subscribeToPushNotifications } from '../networking/api-requests/push.ap
|
|
|
5
5
|
import { subscribeToRoomMessages } from '../networking/xmpp/subscribeToRoomMessages.xmpp';
|
|
6
6
|
|
|
7
7
|
const SUBSCRIBED_ROOMS_KEY = 'ethora_subscribed_rooms';
|
|
8
|
-
// Legacy storage key from before the rename. Read on first load and
|
|
9
|
-
// migrated into SUBSCRIBED_ROOMS_KEY so installed apps don't lose
|
|
10
|
-
// their subscriptions. Safe to remove on the next major version.
|
|
11
|
-
const LEGACY_SUBSCRIBED_ROOMS_KEY = 'preshent_subscribed_rooms';
|
|
12
8
|
|
|
13
9
|
export class PushSubscriptionService {
|
|
14
10
|
private subscribedRooms: Set<string> = new Set();
|
|
@@ -20,23 +16,7 @@ export class PushSubscriptionService {
|
|
|
20
16
|
if (this.isInitialized) {return;}
|
|
21
17
|
|
|
22
18
|
try {
|
|
23
|
-
|
|
24
|
-
if (!storedRooms) {
|
|
25
|
-
// One-time migration from the legacy key.
|
|
26
|
-
try {
|
|
27
|
-
const legacy = await AsyncStorage.getItem(LEGACY_SUBSCRIBED_ROOMS_KEY);
|
|
28
|
-
if (legacy) {
|
|
29
|
-
await AsyncStorage.setItem(SUBSCRIBED_ROOMS_KEY, legacy);
|
|
30
|
-
await AsyncStorage.removeItem(LEGACY_SUBSCRIBED_ROOMS_KEY);
|
|
31
|
-
storedRooms = legacy;
|
|
32
|
-
}
|
|
33
|
-
} catch (migrationError) {
|
|
34
|
-
console.error(
|
|
35
|
-
'[PushService] Legacy storage-key migration failed (subscriptions on this device may be lost):',
|
|
36
|
-
migrationError
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
19
|
+
const storedRooms = await AsyncStorage.getItem(SUBSCRIBED_ROOMS_KEY);
|
|
40
20
|
if (storedRooms) {
|
|
41
21
|
const roomsArray = JSON.parse(storedRooms) as string[];
|
|
42
22
|
this.subscribedRooms = new Set(roomsArray);
|
|
@@ -146,9 +126,6 @@ export class PushSubscriptionService {
|
|
|
146
126
|
|
|
147
127
|
try {
|
|
148
128
|
await AsyncStorage.removeItem(SUBSCRIBED_ROOMS_KEY);
|
|
149
|
-
// Defensive: also clear the legacy key if it somehow survived
|
|
150
|
-
// the migration (e.g. migration failed on first load).
|
|
151
|
-
await AsyncStorage.removeItem(LEGACY_SUBSCRIBED_ROOMS_KEY);
|
|
152
129
|
console.log('[PushService] Subscribed rooms cleared from storage');
|
|
153
130
|
} catch (error) {
|
|
154
131
|
console.error('[PushService] Failed to clear subscribed rooms from storage:', error);
|