Always use the websocket for chat requests
This commit is contained in:
parent
06ff9fa09e
commit
cad30bd216
1 changed files with 4 additions and 15 deletions
|
@ -82,7 +82,6 @@ import type {
|
||||||
ProfileFetchAuthRequestOptions,
|
ProfileFetchAuthRequestOptions,
|
||||||
ProfileFetchUnauthRequestOptions,
|
ProfileFetchUnauthRequestOptions,
|
||||||
} from '../services/profiles';
|
} from '../services/profiles';
|
||||||
import { isMockServer } from '../util/isMockServer';
|
|
||||||
import { ToastType } from '../types/Toast';
|
import { ToastType } from '../types/Toast';
|
||||||
import { isProduction } from '../util/version';
|
import { isProduction } from '../util/version';
|
||||||
import type { ServerAlert } from '../util/handleServerAlerts';
|
import type { ServerAlert } from '../util/handleServerAlerts';
|
||||||
|
@ -798,7 +797,6 @@ type AjaxOptionsType<Type extends ResponseType, OutputShape = unknown> = {
|
||||||
});
|
});
|
||||||
|
|
||||||
export type WebAPIConnectOptionsType = WebAPICredentials & {
|
export type WebAPIConnectOptionsType = WebAPICredentials & {
|
||||||
useWebSocket?: boolean;
|
|
||||||
hasStoriesDisabled: boolean;
|
hasStoriesDisabled: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1862,7 +1860,6 @@ export function initialize({
|
||||||
function connect({
|
function connect({
|
||||||
username: initialUsername,
|
username: initialUsername,
|
||||||
password: initialPassword,
|
password: initialPassword,
|
||||||
useWebSocket = true,
|
|
||||||
hasStoriesDisabled,
|
hasStoriesDisabled,
|
||||||
}: WebAPIConnectOptionsType) {
|
}: WebAPIConnectOptionsType) {
|
||||||
let username = initialUsername;
|
let username = initialUsername;
|
||||||
|
@ -1917,9 +1914,7 @@ export function initialize({
|
||||||
serverAlerts = alerts;
|
serverAlerts = alerts;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (useWebSocket) {
|
void socketManager.authenticate({ username, password });
|
||||||
void socketManager.authenticate({ username, password });
|
|
||||||
}
|
|
||||||
|
|
||||||
const cds = new CDSI(libsignalNet, {
|
const cds = new CDSI(libsignalNet, {
|
||||||
logger: log,
|
logger: log,
|
||||||
|
@ -2123,9 +2118,7 @@ export function initialize({
|
||||||
|
|
||||||
// When host is not provided, assume chat service
|
// When host is not provided, assume chat service
|
||||||
const host = param.host || chatServiceUrl;
|
const host = param.host || chatServiceUrl;
|
||||||
const useWebSocketForEndpoint =
|
const useWebSocketForEndpoint = host === chatServiceUrl;
|
||||||
useWebSocket &&
|
|
||||||
(!param.host || (host === chatServiceUrl && !isMockServer(host)));
|
|
||||||
|
|
||||||
const outerParams: PromiseAjaxOptionsType<Type, OutputShape> = {
|
const outerParams: PromiseAjaxOptionsType<Type, OutputShape> = {
|
||||||
socketManager: useWebSocketForEndpoint ? socketManager : undefined,
|
socketManager: useWebSocketForEndpoint ? socketManager : undefined,
|
||||||
|
@ -2223,18 +2216,14 @@ export function initialize({
|
||||||
username = newUsername;
|
username = newUsername;
|
||||||
password = newPassword;
|
password = newPassword;
|
||||||
|
|
||||||
if (useWebSocket) {
|
await socketManager.authenticate({ username, password });
|
||||||
await socketManager.authenticate({ username, password });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function logout() {
|
async function logout() {
|
||||||
username = '';
|
username = '';
|
||||||
password = '';
|
password = '';
|
||||||
|
|
||||||
if (useWebSocket) {
|
await socketManager.logout();
|
||||||
await socketManager.logout();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSocketStatus(): SocketStatuses {
|
function getSocketStatus(): SocketStatuses {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue