deathandmayhem / jolly-roger

Dead men tell no tales!
MIT License
18 stars 5 forks source link

Display a announcement when a new puzzle is released #164

Open ebroder opened 5 years ago

ebroder commented 5 years ago

Currently there's no signal within Jolly Roger when a new puzzle is created. We should create an announcement when that happens.

Usually, announcements are displayed to all hunters (we create a PendingAnnouncement for every announcement ✗ user), even if they're not currently logged in (we'll load them later). In this case, I think we only want to create the announcement for users that are currently using Jolly Roger. We can probably detect this by using the subCounter mechanism that we use for activity tracking, although we'll also want to track hunters viewing the main hunt page, too.

Here's a rough idea of what's required for this:

As an alternative, we may not want the announcements to actually stick around, even for people that are actively using Jolly Roger. If that's the case, then we probably don't want to go for this implementation at all. Instead, we'd create a new notification type in the NotificationCenter, and then probably populate it entirely client-side using similar logic to the CelebrationCenter (so that they disappear after some period of time).

I think my bias is to create non-transient announcements, but I'm not totally sure.

zarvox commented 5 years ago

I like the client-side-only option better, except that I don't love the fact that the notification will be something that you have to dismiss in every tab.

If we key the in-memory announcement by puzzle ID we could do that kinda hilarious broadcast-via-localStorage-and-storage-observers thing on dismissal to sync the action out to all open tabs. Then I think we get the best of both worlds: users with open tabs will see announcements when new puzzles are created, the server doesn't have to track state, and when you dismiss an announcement in one tab it goes away in all of them.

Thoughts?

ebroder commented 5 years ago

Hmm. When I was imagining the client-side option, I was thinking of a notification that would clear automatically after a short period or something. I feel like I don't have especially strong opinions on what the behavior here should be, since when I'm around for new puzzles getting added, I'm almost always the one adding them.

(Although that reminds me - I would personally find it super spiffy if the person creating the new puzzle didn't get a notification about it.)

Maybe it's worth going outside the tech team a bit to get other people's opinions?

As an aside, @grantaelliott asked in Slack:

Since puzzles are frequently released in groups, how difficult would it be to have the proposed notifications group (share a dismiss button)?

I think that should be doable - the main thing I'd be worried about is race conditions between a dismissing a list of puzzles, and a new puzzle getting added to the list. We'd probably need to do something more sophisticated than my proposal of just re-using PendingAnnouncement if we did server-side tracking. It'd probably work with @zarvox's proposal, so long as the "dismissal" action deleted specific pending puzzles rather than all of them.