Merge branch 'v3.0.x-release' into remove-meteor-stuff-0702

This commit is contained in:
João Victor 2024-07-02 17:46:20 -03:00
commit ac1667b88b
3 changed files with 5160 additions and 16657 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,6 @@ import './App.css';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import Auth from "./Auth";
function App() {
const [sessionToken, setSessionToken] = useState(null);
const [userId, setUserId] = useState(null);
@ -19,7 +18,6 @@ function App() {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const findSessionToken = async () => {
if (urlParams.has('sessionToken')) {
const sessionTokenFromUrl = urlParams.get('sessionToken');
@ -36,6 +34,16 @@ function App() {
findSessionToken();
},[]);
function generateRandomString(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
const charactersLength = characters.length;
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
async function connectGraphqlServer(sessionToken) {
if(sessionToken == null) return;
console.log('connectGraphqlServer');
@ -46,7 +54,9 @@ function App() {
connectionParams: {
headers: {
'X-Session-Token': sessionToken,
'json-patch-supported': 'true'
'X-ClientSessionUUID': generateRandomString(15),
'X-ClientType': 'HTML5',
'X-ClientIsMobile': 'false'
}
},
connectionCallback: (error) => {
@ -102,7 +112,6 @@ function App() {
},[sessionToken]);
return (
<div className="App">
{graphqlClient && graphqlConnected ? (

View File

@ -3,7 +3,7 @@ import React, {useEffect, useState, useRef } from "react";
import {applyPatch} from "fast-json-patch";
export default function UserConnectionStatus() {
const networkRttInMs = useRef(null); // Ref to store the current timeout
const networkRttInMs = useRef(0); // Ref to store the current timeout
const lastStatusUpdatedAtReceived = useRef(null); // Ref to store the current timeout
//example specifying where and time (new Date().toISOString())
@ -24,36 +24,23 @@ export default function UserConnectionStatus() {
//where is not necessary once user can update only its own status
//Hasura accepts "now()" as value to timestamp fields
const [updateUserClientResponseAtToMeAsNow] = useMutation(gql`
mutation UpdateConnectionRtt($networkRttInMs: Float!) {
userSetConnectionRtt(
const [updateConnectionAliveAtToMeAsNow] = useMutation(gql`
mutation UpdateConnectionAliveAt($networkRttInMs: Float!) {
userSetConnectionAlive(
networkRttInMs: $networkRttInMs
)
}
`);
const handleUpdateUserClientResponseAt = () => {
updateUserClientResponseAtToMeAsNow({
variables: {
networkRttInMs: networkRttInMs.current
},
});
};
const [updateConnectionAliveAtToMeAsNow] = useMutation(gql`
mutation UpdateConnectionAliveAt {
userSetConnectionAlive
}
`);
const handleUpdateConnectionAliveAt = () => {
const startTime = performance.now();
try {
updateConnectionAliveAtToMeAsNow().then(result => {
updateConnectionAliveAtToMeAsNow({
variables: {
networkRttInMs: networkRttInMs.current
},
}).then(result => {
const endTime = performance.now();
networkRttInMs.current = endTime - startTime;
@ -120,7 +107,7 @@ export default function UserConnectionStatus() {
lastStatusUpdatedAtReceived.current = curr.statusUpdatedAt;
// setLastStatusUpdatedAtReceived(curr.statusUpdatedAt);
handleUpdateUserClientResponseAt();
// handleUpdateUserClientResponseAt();
}
return (