Set fingerprint locally to avoid webgl rerenders + mem leaks BOD-132
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { all, call, put, takeLatest, delay } from "redux-saga/effects";
|
||||
import { all, call, put, takeLatest, delay, select } from "redux-saga/effects";
|
||||
import LogRocket from "logrocket";
|
||||
import { firestore } from "../../firebase/firebase.utils";
|
||||
import Fingerprint2 from "fingerprintjs2";
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
updateUserDetailsSuccess,
|
||||
setInstanceId,
|
||||
checkInstanceId,
|
||||
setLocalFingerprint,
|
||||
setInstanceConflict,
|
||||
} from "./user.actions";
|
||||
import UserActionTypes from "./user.types";
|
||||
@@ -109,6 +110,7 @@ export function* setInstanceIdSaga({ payload: uid }) {
|
||||
fingerprint,
|
||||
});
|
||||
|
||||
yield put(setLocalFingerprint(fingerprint));
|
||||
yield delay(5000);
|
||||
yield put(checkInstanceId(uid));
|
||||
} catch (error) {
|
||||
@@ -125,12 +127,8 @@ export function* checkInstanceIdSaga({ payload: uid }) {
|
||||
try {
|
||||
const userInstanceRef = firestore.doc(`userInstance/${uid}`);
|
||||
|
||||
const fingerprint = Fingerprint2.x64hash128(
|
||||
(yield Fingerprint2.getPromise({})).map((c) => c.value).join(""),
|
||||
31
|
||||
);
|
||||
|
||||
const snapshot = yield userInstanceRef.get();
|
||||
let fingerprint = yield select((state) => state.user.fingerprint);
|
||||
|
||||
if (snapshot.data().fingerprint === fingerprint) {
|
||||
yield delay(30000);
|
||||
@@ -139,13 +137,8 @@ export function* checkInstanceIdSaga({ payload: uid }) {
|
||||
console.log("ERROR: Fingerprints do not match. Conflict detected.");
|
||||
yield put(setInstanceConflict());
|
||||
}
|
||||
// yield userInstanceRef.set({
|
||||
// timestamp: new Date(),
|
||||
// fingerprint,
|
||||
// });
|
||||
} catch (error) {
|
||||
console.log("error", error);
|
||||
//yield put(signOutFailure(error.message));
|
||||
//TODO error handling
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user