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

show follow notification in tab #1727

Merged
merged 40 commits into from
Jan 31, 2025
Merged

show follow notification in tab #1727

merged 40 commits into from
Jan 31, 2025

Conversation

pelumy
Copy link
Contributor

@pelumy pelumy commented Jan 8, 2025

Issues covered

127
P/S: This needs the backend to send follow notifications as a silent one and not an alert. This needs to be taken into consideration before merging.

Description

I wasn't expecting this PR to turn out this huge, but it did 😿. It contains the following changes:

  • Creates a new core data model version. The NosNotification entity needed a relationship with the Event entity.
  • Refactors the NosNotificationViewModel and NotificationView.
  • Creates a NosNotification and local notification for a silent follow notification.
  • Redefines the NotificationView to shows 3 tabs: "Follows", "In Network" and "Out of Network".
  • Deleting NosNotification reference when an Event is deleted in the DatabaseCleaner. Thanks for fixing this @mplorentz.
  • Deleting NosNotification and Event entities on launch based on a UserDefaults flag.

How to test

  1. Build the app.
  2. Select the Notifications option in the bottom tabs.
    • You should now see three tabs "Follows", "In Network" and "Out of Network".
  3. Please clone this to send a silent push notification. You can change the follower's npub in the json, this example uses Josh's pub. Don't forget to copy your device token and update that part in the notification console. This is a notion doc on how to send push notifications from the console.
    • You should see the notification appear in the Follows tab and also in your iPhone's home Screen.

Screenshots/Video

Post screenshots or video showing your changes, ideally showing how the app worked before and after these changes. Delete this section if this PR contains no visual changes.

Notification tab view

Before After
Before After
Before After
Before After

Video showing follows notification, inNetwork and outOfNetwork.
https://github.com/user-attachments/assets/a08cab0c-0a66-4099-9b8c-3b31b3bee6eb
N/B: I updated the UI after making the video. The screenshot above is the correct UI.

@pelumy pelumy marked this pull request as draft January 8, 2025 21:22
@pelumy pelumy changed the title Ishow follow notification in tab show follow notification in tab Jan 8, 2025
@pelumy pelumy marked this pull request as ready for review January 13, 2025 21:24
@joshuatbrown
Copy link
Contributor

👀

Copy link
Member

@mplorentz mplorentz left a comment

Choose a reason for hiding this comment

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

Hey Itunu, the code looks good to me! There are a couple minor issues I noticed, and some of them are design related. I'm ok to merge and ship this as-is, and we can address these in future PRs.

The first is that I think it would look a lot better to have "Follows" and "Out of Network" centered between "In Network", rather than having them pushed to the edge. This is only an issue on mac/ipad. Also I think it would be good if their tap targets covered the full height of the bar, instead of just the height of the text.
Screenshot 2025-01-28 at 4 54 12 PM

  • This is totally a design thing, but I wish the default tab was "in network", not "Follows". Personally I think I'll be looking at "In Network" the most, "Out of Network" the second-most, and "Follows" the least. What do you think? We could ask about making a change if you also care.
  • I don't like that the badge count is cleared as soon as I tap the notifications tab, even if I haven't viewed all the notifications. We could only mark the visible notifications as read. Again, not a blocker.

@@ -406,4 +406,11 @@ import Logger
// Publish the modified list
await currentUser.publishMuteList(keys: Array(Set(mutedList)))
}

/// Returns true if this event tagged the given author.
func this(author: Author) -> Bool {
Copy link
Member

Choose a reason for hiding this comment

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

I think this name should be a little more descriptive. If I just saw it at the call site like authorA.this(author: authorB) I would probably guess that it was some sort of equality check. The comment is confusing me too, because it says "if this event tagged" but this is a function on Author, so what event are we talking about?

@@ -96,7 +97,90 @@ extension Event {

return fetchRequest
}


/// A request for all out-Of-Network events that the given user should receive.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// A request for all out-Of-Network events that the given user should receive.
/// A request for all out-Of-Network events that the given user should be shown a notification for.

@mplorentz mplorentz self-requested a review January 28, 2025 22:01
mplorentz
mplorentz previously approved these changes Jan 28, 2025
Copy link
Member

@mplorentz mplorentz left a comment

Choose a reason for hiding this comment

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

I meant to click approve on the last one 🙃

@pelumy
Copy link
Contributor Author

pelumy commented Jan 29, 2025

Hey Itunu, the code looks good to me! There are a couple minor issues I noticed, and some of them are design related. I'm ok to merge and ship this as-is, and we can address these in future PRs.

The first is that I think it would look a lot better to have "Follows" and "Out of Network" centered between "In Network", rather than having them pushed to the edge. This is only an issue on mac/ipad. Also I think it would be good if their tap targets covered the full height of the bar, instead of just the height of the text. Screenshot 2025-01-28 at 4 54 12 PM

  • This is totally a design thing, but I wish the default tab was "in network", not "Follows". Personally I think I'll be looking at "In Network" the most, "Out of Network" the second-most, and "Follows" the least. What do you think? We could ask about making a change if you also care.
  • I don't like that the badge count is cleared as soon as I tap the notifications tab, even if I haven't viewed all the notifications. We could only mark the visible notifications as read. Again, not a blocker.

Thanks for your feedbacks @mplorentz. The first point is a bother for me too, thanks for pointing it out. @Chardot what do you think?

For the UI change, I can throw a quick jab at it and see if the change can go with this PR.

@Chardot
Copy link

Chardot commented Jan 29, 2025

Hey Itunu, the code looks good to me! There are a couple minor issues I noticed, and some of them are design related. I'm ok to merge and ship this as-is, and we can address these in future PRs.
The first is that I think it would look a lot better to have "Follows" and "Out of Network" centered between "In Network", rather than having them pushed to the edge. This is only an issue on mac/ipad. Also I think it would be good if their tap targets covered the full height of the bar, instead of just the height of the text. Screenshot 2025-01-28 at 4 54 12 PM

  • This is totally a design thing, but I wish the default tab was "in network", not "Follows". Personally I think I'll be looking at "In Network" the most, "Out of Network" the second-most, and "Follows" the least. What do you think? We could ask about making a change if you also care.
  • I don't like that the badge count is cleared as soon as I tap the notifications tab, even if I haven't viewed all the notifications. We could only mark the visible notifications as read. Again, not a blocker.

Thanks for your feedbacks @mplorentz. The first point is a bother for me too, thanks for pointing it out. @Chardot what do you think?

For the UI change, I can throw a quick jab at it and see if the change can go with this PR.

I agree with @mplorentz's observations about In Network being the default tab on this screen (in fact, that's how I designed it in the first place, but it got changed to Follow).

As discussed with @pelumy today, we decided to make In Network the default tab, while keeping its position in the center to comply with the design that Linda referenced in the ticket, and we can modify the tab bar in a future iteration.

Also agree that the tap surface should cover the full height of the tab bar.

One thing we discussed with @pelumy is how tabs should be spaced between and also centered in the tab bar so that in larger windows on iPads and desktop, the tabs don't get too separated across the screen. We decided to wrap the tabs with a centered container that keeps a maximum width just like the one @martindsq added in the profile view and Feed so that the note cards don't stretch to the full width of the window.

To illustrate how tabs are spaced between, here's an image I made in Figma:
Screenshot 2025-01-29 at 17 48 36
Tab labels have variable width, but the space left in the tab bar is evenly split around them.

@pelumy
Copy link
Contributor Author

pelumy commented Jan 29, 2025

Based on the above comments, this is the updated UI.

Mac/iPad:

Screenshot 2025-01-29 at 7 28 48 pm

iPhone:

Screenshot 2025-01-29 at 7 29 43 pm

@mplorentz
Copy link
Member

@pelumy the Mac/iPad screenshot you posted doesn't seem to follow the "space around" spacing that Sebastian described. Is that something you were intending to include in this PR or to add somewhere else?

@pelumy
Copy link
Contributor Author

pelumy commented Jan 29, 2025

@pelumy the Mac/iPad screenshot you posted doesn't seem to follow the "space around" spacing that Sebastian described. Is that something you were intending to include in this PR or to add somewhere else?

@mplorentz , it has been corrected. thanks for pointing it out:

Screenshot 2025-01-29 at 11 38 33 pm

@mplorentz mplorentz requested a review from martindsq as a code owner January 31, 2025 19:29
@mplorentz
Copy link
Member

👀

Copy link
Member

@mplorentz mplorentz left a comment

Choose a reason for hiding this comment

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

Unfortunately I'm still seeing one minor layout issue. The tab bar is not extending to the edges of the screen on my Mac. I think it is probably inside a container using .readabilityPadding(), but that should only be used on the content.

@mplorentz mplorentz dismissed their stale review January 31, 2025 19:48

found a bug

@pelumy
Copy link
Contributor Author

pelumy commented Jan 31, 2025

Thanks for catching that @mplorentz. The UI has been updated.

Screenshot 2025-01-31 at 9 06 10 pm

@pelumy
Copy link
Contributor Author

pelumy commented Jan 31, 2025

This new failing test is not failing for me locally. I'm not sure what is wrong.

Copy link
Member

@mplorentz mplorentz left a comment

Choose a reason for hiding this comment

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

I ran the tests again and they passed. They also pass for me locally. Let's chalk it up to a random failure. Merge away!

@pelumy pelumy added this pull request to the merge queue Jan 31, 2025
Merged via the queue into main with commit 5d0ca91 Jan 31, 2025
4 checks passed
@pelumy pelumy deleted the it/127-follow-notification branch January 31, 2025 21:28
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.

4 participants