[CHORE] Use Rocket.Chat JS SDK's official repo (#2440)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
91a2e9b181
commit
8e4eb49b2e
|
@ -42,7 +42,7 @@
|
||||||
"@react-navigation/native": "5.7.0",
|
"@react-navigation/native": "5.7.0",
|
||||||
"@react-navigation/stack": "5.7.0",
|
"@react-navigation/stack": "5.7.0",
|
||||||
"@rocket.chat/react-native-fast-image": "^8.1.5",
|
"@rocket.chat/react-native-fast-image": "^8.1.5",
|
||||||
"@rocket.chat/sdk": "djorkaeffalexandre/Rocket.Chat.js.SDK#test.fix-ddp",
|
"@rocket.chat/sdk": "RocketChat/Rocket.Chat.js.SDK#mobile",
|
||||||
"@rocket.chat/ui-kit": "0.13.0",
|
"@rocket.chat/ui-kit": "0.13.0",
|
||||||
"bugsnag-react-native": "2.23.10",
|
"bugsnag-react-native": "2.23.10",
|
||||||
"commonmark": "git+https://github.com/RocketChat/commonmark.js.git",
|
"commonmark": "git+https://github.com/RocketChat/commonmark.js.git",
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
diff --git a/node_modules/@rocket.chat/sdk/lib/api/api.ts b/node_modules/@rocket.chat/sdk/lib/api/api.ts
|
|
||||||
index 17c2c2b..cb094e8 100644
|
|
||||||
--- a/node_modules/@rocket.chat/sdk/lib/api/api.ts
|
|
||||||
+++ b/node_modules/@rocket.chat/sdk/lib/api/api.ts
|
|
||||||
@@ -117,24 +117,31 @@ class Client implements IClient {
|
|
||||||
JSON.stringify(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
+ getSignal (options?: any): AbortSignal {
|
|
||||||
+ return options && options.signal;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
get (url: string, data: any, options?: any): Promise<any> {
|
|
||||||
return fetch(`${this.host}/api/v1/${encodeURI(url)}?${this.getParams(data)}`, {
|
|
||||||
method: 'GET',
|
|
||||||
- headers: this.getHeaders(options)
|
|
||||||
+ headers: this.getHeaders(options),
|
|
||||||
+ signal: this.getSignal(options)
|
|
||||||
}).then(this.handle)
|
|
||||||
}
|
|
||||||
post (url: string, data: any, options?: any): Promise<any> {
|
|
||||||
return fetch(`${this.host}/api/v1/${encodeURI(url)}`, {
|
|
||||||
method: 'POST',
|
|
||||||
body: this.getBody(data),
|
|
||||||
- headers: this.getHeaders(options)
|
|
||||||
+ headers: this.getHeaders(options),
|
|
||||||
+ signal: this.getSignal(options)
|
|
||||||
}).then(this.handle)
|
|
||||||
}
|
|
||||||
put (url: string, data: any, options?: any): Promise<any> {
|
|
||||||
return fetch(`${this.host}/api/v1/${encodeURI(url)}`, {
|
|
||||||
method: 'PUT',
|
|
||||||
body: this.getBody(data),
|
|
||||||
- headers: this.getHeaders(options)
|
|
||||||
+ headers: this.getHeaders(options),
|
|
||||||
+ signal: this.getSignal(options)
|
|
||||||
}).then(this.handle)
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -142,7 +149,8 @@ class Client implements IClient {
|
|
||||||
return fetch(`${this.host}/api/v1/${encodeURI(url)}`, {
|
|
||||||
method: 'DELETE',
|
|
||||||
body: this.getBody(data),
|
|
||||||
- headers: this.getHeaders(options)
|
|
||||||
+ headers: this.getHeaders(options),
|
|
||||||
+ signal: this.getSignal(options)
|
|
||||||
}).then(this.handle)
|
|
||||||
}
|
|
||||||
private async handle (r: any) {
|
|
||||||
@@ -176,11 +184,13 @@ export default class Api extends EventEmitter {
|
|
||||||
authToken: string,
|
|
||||||
result: ILoginResultAPI
|
|
||||||
} | null = null
|
|
||||||
+ controller: AbortController
|
|
||||||
|
|
||||||
constructor ({ client, host, logger = Logger }: any) {
|
|
||||||
super()
|
|
||||||
this.client = client || new Client({ host } as any)
|
|
||||||
this.logger = Logger
|
|
||||||
+ this.controller = new AbortController();
|
|
||||||
}
|
|
||||||
|
|
||||||
get username () {
|
|
||||||
@@ -212,6 +222,10 @@ export default class Api extends EventEmitter {
|
|
||||||
if (auth && !this.loggedIn()) {
|
|
||||||
throw new Error('')
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ const { signal } = this.controller;
|
|
||||||
+ options = { ...options, signal };
|
|
||||||
+
|
|
||||||
let result
|
|
||||||
switch (method) {
|
|
||||||
case 'GET': result = await this.client.get(endpoint, data, options); break
|
|
||||||
@@ -242,6 +256,8 @@ export default class Api extends EventEmitter {
|
|
||||||
/** Do a DELETE request to an API endpoint. */
|
|
||||||
del: IAPIRequest = (endpoint, data, auth, ignore, options = {}) => this.request('DELETE', endpoint, data, auth, ignore, options)
|
|
||||||
|
|
||||||
+ abort = (): void => this.controller.abort()
|
|
||||||
+
|
|
||||||
/** Check result data for success, allowing override to ignore some errors */
|
|
||||||
success (result: any, ignore?: RegExp) {
|
|
||||||
return (
|
|
||||||
diff --git a/node_modules/@rocket.chat/sdk/lib/drivers/ddp.ts b/node_modules/@rocket.chat/sdk/lib/drivers/ddp.ts
|
|
||||||
index 247ce8b..2687abc 100644
|
|
||||||
--- a/node_modules/@rocket.chat/sdk/lib/drivers/ddp.ts
|
|
||||||
+++ b/node_modules/@rocket.chat/sdk/lib/drivers/ddp.ts
|
|
||||||
@@ -538,7 +538,8 @@ export class DDPDriver extends EventEmitter implements ISocket, IDriver {
|
|
||||||
'notification',
|
|
||||||
'rooms-changed',
|
|
||||||
'subscriptions-changed',
|
|
||||||
- 'uiInteraction'
|
|
||||||
+ 'uiInteraction',
|
|
||||||
+ 'userData'
|
|
||||||
].map(event => this.subscribe(topic, `${this.userId}/${event}`, false)))
|
|
||||||
}
|
|
||||||
|
|
|
@ -2227,9 +2227,9 @@
|
||||||
resolved "https://registry.yarnpkg.com/@rocket.chat/react-native-fast-image/-/react-native-fast-image-8.1.5.tgz#325d80ebb351fb024436093b3e2add280696aba3"
|
resolved "https://registry.yarnpkg.com/@rocket.chat/react-native-fast-image/-/react-native-fast-image-8.1.5.tgz#325d80ebb351fb024436093b3e2add280696aba3"
|
||||||
integrity sha512-ZjSt7NXiCkJ9KQr4b/b+mYgiwDAIGHfHdChgEU020C9sBbhSk6VxslqnfdZoAjxRW7doWMbhWkoYMjx2TnsGRw==
|
integrity sha512-ZjSt7NXiCkJ9KQr4b/b+mYgiwDAIGHfHdChgEU020C9sBbhSk6VxslqnfdZoAjxRW7doWMbhWkoYMjx2TnsGRw==
|
||||||
|
|
||||||
"@rocket.chat/sdk@djorkaeffalexandre/Rocket.Chat.js.SDK#test.fix-ddp":
|
"@rocket.chat/sdk@RocketChat/Rocket.Chat.js.SDK#mobile":
|
||||||
version "1.0.0-dj.15"
|
version "1.0.0-mobile"
|
||||||
resolved "https://codeload.github.com/djorkaeffalexandre/Rocket.Chat.js.SDK/tar.gz/216de62f7e52dd4a9f73d7989d6943ced550a92a"
|
resolved "https://codeload.github.com/RocketChat/Rocket.Chat.js.SDK/tar.gz/0a97c818e60670d7660868ea107b96e5ebb631af"
|
||||||
dependencies:
|
dependencies:
|
||||||
js-sha256 "^0.9.0"
|
js-sha256 "^0.9.0"
|
||||||
lru-cache "^4.1.1"
|
lru-cache "^4.1.1"
|
||||||
|
|
Loading…
Reference in New Issue