feat: differ staging cookie
Some checks failed
Release / build (ubuntu-latest) (push) Has been cancelled
Release / build (windows-latest) (push) Has been cancelled

This commit is contained in:
Zamitto 2024-12-09 19:29:31 -03:00
parent 45f2727415
commit d8b59cae05
2 changed files with 8 additions and 5 deletions

View File

@ -1,15 +1,17 @@
export function addCookieInterceptor() { export function addCookieInterceptor(isStaging: boolean) {
const cookieKey = isStaging ? "cookies-staging" : "cookies";
Object.defineProperty(document, "cookie", { Object.defineProperty(document, "cookie", {
enumerable: true, enumerable: true,
configurable: true, configurable: true,
get() { get() {
return localStorage.getItem("cookies") || ""; return localStorage.getItem(cookieKey) || "";
}, },
set(cookieString) { set(cookieString) {
try { try {
const [cookieName, cookieValue] = cookieString.split(";")[0].split("="); const [cookieName, cookieValue] = cookieString.split(";")[0].split("=");
const currentCookies = localStorage.getItem("cookies") || ""; const currentCookies = localStorage.getItem(cookieKey) || "";
const cookiesObject = parseCookieStringsToObjects(currentCookies); const cookiesObject = parseCookieStringsToObjects(currentCookies);
cookiesObject[cookieName] = cookieValue; cookiesObject[cookieName] = cookieValue;
@ -20,7 +22,7 @@ export function addCookieInterceptor() {
}) })
.join("; "); .join("; ");
localStorage.setItem("cookies", newString); localStorage.setItem(cookieKey, newString);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} }

View File

@ -38,7 +38,8 @@ const Achievements = React.lazy(
console.log = logger.log; console.log = logger.log;
addCookieInterceptor(); const isStaging = await window.electron.isStaging();
addCookieInterceptor(isStaging);
i18n i18n
.use(LanguageDetector) .use(LanguageDetector)