Skip to content

Commit 899d21b

Browse files
authored
fix: use centralized fetch helper (#6664)
1 parent 216b30f commit 899d21b

File tree

6 files changed

+10
-3
lines changed

6 files changed

+10
-3
lines changed

app/lib/methods/getServerInfo.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { settings as RocketChatSettings } from '@rocket.chat/sdk';
21
import { KJUR } from 'jsrsasign';
32
import moment from 'moment';
43

@@ -12,6 +11,7 @@ import { getServerById } from '../database/services/Server';
1211
import { compareServerVersion } from './helpers';
1312
import log from './helpers/log';
1413
import { getUserSelector } from '../../selectors/login';
14+
import fetch from './helpers/fetch';
1515

1616
interface IServerInfoFailure {
1717
success: false;
@@ -52,7 +52,6 @@ export async function getServerInfo(server: string): Promise<TServerInfoResult>
5252
const response = await fetch(`${server}/api/info`, {
5353
method: 'GET',
5454
headers: {
55-
...RocketChatSettings.customHeaders,
5655
'Content-Type': 'application/json',
5756
'X-Auth-Token': user?.token,
5857
'X-User-Id': user?.id

app/lib/methods/sendFileMessage/sendFileMessageV2.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Encryption } from '../../encryption';
66
import { copyFileToCacheDirectoryIfNeeded, createUploadRecord, persistUploadError, uploadQueue } from './utils';
77
import FileUpload from '../helpers/fileUpload';
88
import { IFormData } from '../helpers/fileUpload/definitions';
9+
import fetch from '../helpers/fetch';
910

1011
export async function sendFileMessageV2(
1112
rid: string,

app/lib/services/connect.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { _setUser, type IActiveUsers, _setUserTimer, _activeUsers } from '../met
2626
import { compareServerVersion } from '../methods/helpers/compareServerVersion';
2727
import { isIOS } from '../methods/helpers/deviceInfo';
2828
import { isSsl } from '../methods/helpers/isSsl';
29+
import fetch from '../methods/helpers/fetch';
2930

3031
interface IServices {
3132
[index: string]: string | boolean;

app/lib/services/getServerTimeSync.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import fetch from '../methods/helpers/fetch';
2+
13
export const getServerTimeSync = async (server: string) => {
24
try {
35
const response = await Promise.race([fetch(`${server}/_timesync`), new Promise<undefined>(res => setTimeout(res, 2000))]);

app/lib/services/restApi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { compareServerVersion, getBundleId, isIOS } from '../methods/helpers';
2424
import { getDeviceToken } from '../notifications';
2525
import { store as reduxStore } from '../store/auxStore';
2626
import sdk from './sdk';
27+
import fetch from '../methods/helpers/fetch';
2728

2829
export const createChannel = ({
2930
name,

app/views/AuthenticationWebView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useAppSelector } from '../lib/hooks';
1414
import { useDebounce } from '../lib/methods/helpers';
1515
import { Services } from '../lib/services';
1616
import { OutsideModalParamList } from '../stacks/types';
17+
import fetch, { type TMethods } from '../lib/methods/helpers/fetch';
1718

1819
// iframe uses a postMessage to send the token to the client
1920
// We'll handle this sending the token to the hash of the window.location
@@ -76,7 +77,9 @@ const AuthenticationWebView = () => {
7677

7778
const tryLogin = useDebounce(
7879
async () => {
79-
const data = await fetch(Accounts_Iframe_api_url, { method: Accounts_Iframe_api_method }).then(response => response.json());
80+
const data = await fetch(Accounts_Iframe_api_url, { method: Accounts_Iframe_api_method as TMethods }).then(response =>
81+
response.json()
82+
);
8083
const resume = data?.login || data?.loginToken;
8184
if (resume) {
8285
login({ resume });

0 commit comments

Comments
 (0)