This commit is contained in:
lingdocs 2021-08-25 01:50:10 +04:00
parent e5659fc5ad
commit f51082c463
2 changed files with 8 additions and 5 deletions

View File

@ -20,8 +20,7 @@ function setupSession(app: Express) {
maxAge: 1000 * 60 * 60 * 24 * 7 * 30 * 6,
secure: inProd,
domain: inProd ? "lingdocs.com" : undefined,
// TODO: TRY TO SET TO TRUE
httpOnly: false,
httpOnly: true,
},
store: inProd
? new RedisStore({ client: redis.createClient() })

View File

@ -264,6 +264,7 @@ class App extends Component<RouteComponentProps, State> {
private async handleLoadUser(): Promise<void> {
try {
console.log("loading user");
const prevUser = this.state.user;
const userOnServer = await getUser();
if (userOnServer === "offline") return;
@ -273,8 +274,10 @@ class App extends Component<RouteComponentProps, State> {
saveUser(undefined);
return;
}
const { userTextOptionsRecord, serverOptionsAreNewer } = resolveTextOptions(userOnServer, prevUser, this.state.options.textOptionsRecord);
const user: AT.LingdocsUser | undefined = {
const { userTextOptionsRecord, serverOptionsAreNewer } = resolveTextOptions(userOnServer, prevUser, this.state.options.textOptionsRecord);
console.log("resolvedUserTextOptionsRecord", userTextOptionsRecord);
console.log("serverRecordIsNewer", serverOptionsAreNewer);
const user: AT.LingdocsUser = {
...userOnServer,
userTextOptionsRecord,
};
@ -289,6 +292,7 @@ class App extends Component<RouteComponentProps, State> {
};
this.handleOptionsUpdate({ type: "updateTextOptionsRecord", payload: textOptionsRecord });
if (!serverOptionsAreNewer) {
console.log("gonna save the new text options");
updateUserTextOptionsRecord(userTextOptionsRecord);
}
if (user) {
@ -394,7 +398,7 @@ class App extends Component<RouteComponentProps, State> {
}
}
private checkUserCronJob = new CronJob("* * * * *", () => {
private checkUserCronJob = new CronJob("1/20 * * * * *", () => {
this.handleLoadUser();
})