Skip to content

setNotificationsLastSeenAt and add the value to getNotifications call #55

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

Merged
merged 3 commits into from
Feb 25, 2021

Conversation

jsonsivar
Copy link
Contributor

Description

This adds the setNotificationsLastSeenAt so the FE can set it. And also getNotifications now returns this value properly.

https://app.clubhouse.io/terminalsystems/story/21022/setnotificationslastseenat

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Unit Test
  • Integration Test

Checklist:

  • My code follows the style guidelines of this project
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@shortcut-integration
Copy link

This pull request has been linked to Clubhouse Story #21022: SetNotificationsLastSeenAt.

Copy link
Contributor

@perfectmak perfectmak left a comment

Choose a reason for hiding this comment

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

LGTM!. I left two comments and we should be good to go.

const encryptedTimestamp = await this.encrypt(timestamp.toString());
const lookupKey = this.getNotificationsLastSeenAtLookupKey();
const nodeRef = this.lookupUser.get(lookupKey).put({ data: encryptedTimestamp });
this.listUser.get(NotificationsLastSeenAtCollection).set(nodeRef as unknown as EncryptedMetadata);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to add it to a set() here. The set is useful if we need a list of all last seen at timestamp right? And I don't think we would need that. We are only interested in setting and getting that data right? So the put() should be fine. It would always override the latest value.

@@ -478,6 +499,10 @@ export class GundbMetadataStore implements UserMetadataStore {
});
}

private getNotificationsLastSeenAtLookupKey(): string {
return `notifications/lastSeenAt/${this.username}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return `notifications/lastSeenAt/${this.username}`;
return `notifications/lastSeenAt`;

Since the key already namespaced to the user, we shouldn't need to add the username field to the lookup key

@jsonsivar jsonsivar merged commit 5d7b5db into master Feb 25, 2021
@perfectmak perfectmak deleted the feature/ch21022/set-notifs-last-seen branch March 19, 2021 11:32
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.

2 participants