A small module builds actions for the notifications panel and prepares channel labels for display in the interface. After a recent change, the panel started behaving strangely: actions for different channels look the same, and some notifications suddenly disappear from the selection.
build_channel_actions(channels) must return a dictionary where:
open:<channel> for its channel.collect_visible_notifications(notifications, allowed_channels) must:
channel field is included in allowed_channels;from notifications import build_channel_actions
actions = build_channel_actions(["email", "sms", "push"])
print(actions["email"]())
print(actions["sms"]())
print(actions["push"]())
from notifications import collect_visible_notifications
stream = (
{"id": item[0], "channel": item[1]}
for item in [(1, "email"), (2, "push"), (3, "sms"), (4, "push")]
)
print(collect_visible_notifications(stream, {"push", "sms"}))
CPython 3.12asyncionotifications.pyid and channel; the value of allowed_channels is a set or another container supporting the in operationUse line comments to explain the problem, its impact, the fix and how to test it.