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

Updated Notification behaviour #1626

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kiminkim724
Copy link
Collaborator

@kiminkim724 kiminkim724 commented Sep 24, 2024

Summary

  • Based off of last week's discussion:
    • The notifications have been split between BillHistoryUpdateNotification and TestimonySubmitNotification
    • These notifications will have flags that will determine which notifications to display when it's filtered on the Newsfeed.
    • Added an position icon to the testimony notifications

Checklist

  • On the frontend, I've made my strings translate-able.
  • If I've added shared components, I've added a storybook story.
  • I've made pages responsive and look good on mobile.

Screenshots

Screen Shot 2024-09-24 at 7 16 16 PM

Known issues

If you've run against limitations or caveats, include them here. Include follow-up issues as well.

Steps to test/reproduce

For each feature or bug fix, create a step by step list for how a reviewer can test it out. E.g.:

  1. Follow a bill or organization
  2. Have a person/organization post on the bill
  3. Check newsfeed to see if it's populated properly

Copy link

vercel bot commented Sep 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
maple-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 11:20pm
maple-prod 🔄 Building (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 11:20pm

Copy link
Collaborator

@Mephistic Mephistic left a comment

Choose a reason for hiding this comment

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

Love the progress here! I had a few notes I'd like to check in on before we push this out - not sure if it's an issue with the code itself or just my understanding.

I also think we've hit the level of complexity here where a few basic unit and/or integration tests would actually speed up development by adding clarity - doesn't have to part of this PR, but we should earmark it for near future work.

@@ -7,15 +7,17 @@ export interface Notification {
billCourt: string
billId: string
billName: string
/*isBillMatch: boolean
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should these still be commented out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They're unnecessary, so they should be deleted now

id: entity.billId,
subheader: subheader,
timestamp: entity.updateTime,
type: entity.type,
court,
position: position ?? "",
isBillMatch: entity.type === "bill" || entity.type === "testimony",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just want to double-check the logic here

As I understand it, there are three options here:

  • BillHistoryUpdateNotification
  • TestimonySubmittedNotification (for testimony on a followed bill)
  • TestimonySubmittedNotification (for testimony from a followed user/org)

It seems like isBillMatch would currently be true for the third condition (where the notification is for a user following another user who submitted testimony), but should be false. Does that seem right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, correct. Should be fixed now.

) => {
const notificationFields = createNotificationFields(topic)

console.log(JSON.stringify(notificationFields))

const topicNameSnapshot = await db
.collectionGroup("activeTopicSubscriptions")
.where("topicName", "==", notificationFields.topicName)
.where("topicName", "in", notificationFields.topicName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure this has solved the duplication problem? It looks like if we match on two rules for the same user, it would return two snapshots here (e.g. one for the bill topic and one for the org/user topic) and we would create one notification for each snapshot.

It might be helpful to:

  • Wait to createNotificationFields until we know which topics we matched on
  • Group the returned activeTopicSubscriptions by uid
  • Extract the matching follow types (billFollow vs userFollow) from the activeTopicSubscriptions
  • For each uid, run createNotificationFields only now that we know which follows types triggered the notification and can set isBillMatch/isUserMatch for each user's notificatiion accordingly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are correct, it didn't solve the duplication problem. I thought it solved the duplication problem because the notifications didn't appear, but it's because the topicName that was being created was prefixed with org instead of testimony, so it never populated the notification. I've updated the code to reflect your suggestions.

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