Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-4436 update session only in touchSession #2377

Merged
merged 50 commits into from
Feb 23, 2024

Conversation

alexander-skoblikov
Copy link
Collaborator

No description provided.

webapp/packages/core-activity/src/ClientActivityService.ts Outdated Show resolved Hide resolved
webapp/packages/core-activity/src/ClientActivityService.ts Outdated Show resolved Hide resolved
webapp/packages/core-app/src/useClientActivity.ts Outdated Show resolved Hide resolved
@@ -95,6 +92,23 @@ export class SessionResource extends CachedDataResource<SessionState | null> {
return session;
}

touchSession = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid the use of arrow functions. It's hard to debug

webapp/packages/core-root/src/SessionResource.ts Outdated Show resolved Hide resolved
}

if (this.data?.valid) {
this.graphQLService.sdk.touchSession();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call will update the session lifetime. We need to read the session from this method and update setData of the resource like it was in refreshSilent

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this abstraction to avoid cyclic dependency

try {
await this.sessionResource.touchSession();
} catch (e) {
console.error('Session touch error', e);
Copy link
Contributor

@sergeyteleshev sergeyteleshev Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is forbidden to import notificationService into core-root, so I logged it with this

try {
await this.sessionResource.updateSession();
} catch (e) {
console.error('Session update error', e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot import NotificationService here so just logged it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can move it to plugin-session-expiration (not the best place but it's ok)

@sergeyteleshev sergeyteleshev requested a review from Wroud February 20, 2024 10:35
Comment on lines +36 to +41
this.touchSessionTimer = setTimeout(() => {
if (this.touchSessionTimer) {
clearTimeout(this.touchSessionTimer);
this.touchSessionTimer = null;
}
}, SESSION_TOUCH_TIME_PERIOD);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep naming for constants also (notifyClientActivity)

return;
}

const session = (await this.graphQLService.sdk.updateSession()).updateSession;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use object destructuring here

try {
await this.sessionResource.updateSession();
} catch (e) {
console.error('Session update error', e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can move it to plugin-session-expiration (not the best place but it's ok)

@alexander-skoblikov alexander-skoblikov merged commit c0c4e18 into devel Feb 23, 2024
3 of 5 checks passed
@serge-rider serge-rider deleted the CB-4346-session-doesnt-expire-after-30-min branch March 22, 2024 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants