Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/services/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { settings } from './settings';
import { getEncodedUserToken } from "../managers/user-manager";

export function UserNetworkInstance() {
const baseURL =
settings.getQueueAPIVersion() === "3"
? settings.GIST_QUEUE_V3_API_ENDPOINT[Gist.config.env]
: settings.GIST_QUEUE_API_ENDPOINT[Gist.config.env];

const baseURL = settings.GIST_QUEUE_API_ENDPOINT[Gist.config.env]
const defaultHeaders = {
'X-CIO-Site-Id': Gist.config.siteId,
'X-CIO-Client-Platform': 'web',
Expand Down
18 changes: 1 addition & 17 deletions src/services/queue-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ export async function getUserQueue() {
"X-Gist-User-Anonymous": isUsingGuestUserToken(),
"Content-Language": getUserLocale()
}

if (settings.getQueueAPIVersion() === "3") {
response = await UserNetworkInstance().post(`/api/v3/users?sessionId=${getSessionId()}`, {}, { headers: headers });
} else {
var timestamp = new Date().getTime();
response = await UserNetworkInstance().post(`/api/v2/users?timestamp=${timestamp}`, {}, { headers: headers });
}
response = await UserNetworkInstance().post(`/api/v3/users?sessionId=${getSessionId()}`, {}, { headers: headers });
}
} catch (error) {
if (error.response) {
Expand All @@ -39,22 +33,12 @@ export async function getUserQueue() {
} finally {
checkInProgress = false;
scheduleNextQueuePull(response);
setQueueAPIVersion(response);
setQueueUseSSE(response);
}

return response;
}

function setQueueAPIVersion(response) {
if (response && response.headers) {
var queueVersion = response.headers["x-cio-queue-version"];
if (queueVersion) {
settings.setQueueAPIVersion(queueVersion);
}
}
}

function setQueueUseSSE(response) {
const useSSE = response?.headers?.["x-cio-use-sse"]?.toLowerCase() === "true";
settings.setUseSSEFlag(useSSE);
Expand Down
14 changes: 0 additions & 14 deletions src/services/settings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { getKeyFromLocalStore, setKeyToLocalStore, clearKeyFromLocalStore } from '../utilities/local-storage';
import { log } from '../utilities/log';
import { v4 as uuidv4 } from 'uuid';
const userQueueVersionLocalStoreName = "gist.web.userQueueVersion";
const userQueueUseSSELocalStoreName = "gist.web.userQueueUseSSE";
const userQueueActiveSSEConnectionLocalStoreName = "gist.web.activeSSEConnection";
const heartbeatSlop = 5;
Expand All @@ -16,11 +15,6 @@ export const settings = {
"local": "http://engine.api.local.gist.build:82"
},
GIST_QUEUE_API_ENDPOINT: {
"prod": "https://gist-queue-consumer-api.cloud.gist.build",
"dev": "https://gist-queue-consumer-api.cloud.dev.gist.build",
"local": "http://api.local.gist.build:86"
},
GIST_QUEUE_V3_API_ENDPOINT: {
"prod": "https://consumer.cloud.gist.build",
"dev": "https://consumer.cloud.dev.gist.build",
"local": "http://api.local.gist.build:86"
Expand All @@ -41,14 +35,6 @@ export const settings = {
}
return sdkId;
},
getQueueAPIVersion: function() {
return getKeyFromLocalStore(userQueueVersionLocalStoreName) ?? "2";
},
setQueueAPIVersion: function(version) {
// The Queue API version TTL is renewed with every poll request and extended by 30 minutes.
setKeyToLocalStore(userQueueVersionLocalStoreName, version, new Date(new Date().getTime() + 1800000));
log(`Set user queue version to "${version}"`);
},
useSSE: function() {
return getKeyFromLocalStore(userQueueUseSSELocalStoreName) ?? false;
},
Expand Down