gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit97f77b0797f77b07ident mission 012 (WIP): onto the layouts theme dbe3de7, shell on AppHeader/MainMenu/UserMenu/Sidebar + ContentFirst, styles cut, check-theme gatemre97f77b07/components/inbox.hl

4.1 KB

  1. // components/inbox.hl — `/inbox`: THE NOTIFICATIONS INBOX (piece 4 of 6, ticket ident#6;
  2. // CONCEPT.md "Notifications": "The user reads them in ident's notifications inbox").
  3. // Every notification of every identity of the signed-in account, newest first: identity,
  4. // app, name, text, icon, action link, time; read / unread (a button per notification).
  5. // Below: the apps the account's identities are registered in — each links to its per-app
  6. // page (`/inbox/<connection id>`, components/appsettings.hl).
  7. //
  8. // Faces are named `inbox…` (a face is found by its EVENT NAME across all files).
  9. parent './main.hl'
  10. import { accountOfSession } from '../lib/accounts.hl'
  11. import { inboxRows, markRead, connectionRows } from '../lib/notify.hl'
  12. import { unreadCount } from '../lib/notify-helpers.hl'
  13. import { siteName } from '../project.hl'
  14. session = null
  15. me = accountOfSession(session)
  16. signedIn = me != null
  17. signedOut = me == null
  18. meEmail = me != null ? me.email : ''
  19. items = me != null ? inboxRows(me.id) : []
  20. hasItems = items.length > 0
  21. noItems = items.length == 0
  22. unread = unreadCount(items)
  23. unreadText = unread == 1 ? '1 unread' : unread + ' unread'
  24. conns = me != null ? connectionRows(me.id) : []
  25. hasConns = conns.length > 0
  26. noConns = conns.length == 0
  27. current = '/inbox'
  28. __title = siteName + ' | inbox'
  29. message = ''
  30. View {
  31. identCard { class = "wide"
  32. if (signedOut) {
  33. h1 { "Inbox" }
  34. p { id = "signinfirst" class = "lead" "Sign in to ident first: " a { href = "/" "sign in" } "." }
  35. }
  36. if (signedIn) {
  37. accountBar {
  38. userEmail { id = "meemail" meEmail }
  39. unreadTotal { id = "unreadcount" unreadText }
  40. }
  41. section { id = "inboxsection"
  42. h1 { "Inbox" }
  43. if (noItems) { p { id = "noitems" class = "lead" "No notifications yet. Apps you signed in to with ident can send you some; they show up here." } }
  44. ul { id = "inbox"
  45. for (n of items) {
  46. li { class = n.state
  47. if (n.hasIcon) { img { class = "icon" src = n.icon alt = "" width = "40" height = "40" loading = "lazy" referrerpolicy = "no-referrer" } }
  48. noteMain {
  49. noteHead {
  50. noteName { n.name }
  51. if (n.urgent) { urgentBadge { "urgent" } }
  52. if (n.unread) { unreadBadge { "new" } }
  53. }
  54. noteFrom { n.app " · " n.identity }
  55. noteText { n.text }
  56. noteFoot {
  57. time { n.time }
  58. if (n.hasLink) { a { class = "action" href = n.link target = "_blank" rel = "noopener noreferrer" "Open" } }
  59. button { type = "button" class = "quiet small toggle" value = n.id n.toggleText on click(e) { emit toggle(e.target.value) } }
  60. }
  61. }
  62. }
  63. }
  64. }
  65. }
  66. section { id = "connsection"
  67. h2 { "Notification settings per app" }
  68. if (noConns) { p { id = "noconns" class = "lead" "None of your identities is registered in an app yet." } }
  69. ul { id = "conns"
  70. for (c of conns) {
  71. li {
  72. a { class = "conn" href = c.href c.app }
  73. connDetails { c.identity " · since " c.since }
  74. }
  75. }
  76. }
  77. }
  78. }
  79. p { id = "message" class = "message" message }
  80. }
  81. }
  82. rowOf = (id) => {
  83. for (n of items) { if ('' + n.id == '' + id) { return n } }
  84. return null
  85. }
  86. setItems = (list) => {
  87. items = list
  88. hasItems = list.length > 0
  89. noItems = list.length == 0
  90. let u = 0
  91. for (n of list) { if (n.unread) { u = u + 1 } }
  92. unread = u
  93. unreadText = u == 1 ? '1 unread' : u + ' unread'
  94. return null
  95. }
  96. on toggle(id) {
  97. message = ''
  98. row = rowOf(id)
  99. if (row == null) { return null }
  100. r = emit server inboxMark('' + id, !row.read)
  101. if (r == null) {
  102. message = 'the server did not answer — try again'
  103. return null
  104. }
  105. if (r.error != null) {
  106. message = r.error
  107. return null
  108. }
  109. setItems(r.items)
  110. }
  111. // ---- the faces ------------------------------------------------------------------------
  112. // The LAST parameter is the session; accountOfSession only accepts the framework's own
  113. // Session (hl:web never takes it from the peer, hybriel#16/#31).
  114. on server inboxMark(id, read, session) {
  115. let me = accountOfSession(session)
  116. if (me == null) { return { error = 'you are not signed in' } }
  117. r = markRead(me.id, id, read)
  118. if (r.error != null) { return r }
  119. return { items = inboxRows(me.id) }
  120. }

Branches

Latest commits

  • 97f77b07ident mission 012 (WIP): onto the layouts theme dbe3de7, shell on AppHeader/MainMenu/UserMenu/Sidebar + ContentFirst, styles cut, check-theme gatemre
  • 8e4f435bpaths: projects moved into /media/STORAGE/projects/WorldAPI/mre
  • fa288f63ident mission 011: report wording (Intl zone names)mre
  • 961fae01ident mission 011: report, LOG, STATUSmre
  • 65348039ident#7: delivery gate — console check split at the gate's own server restart (49 checks)mre
  • dfa7b783ident#7: README (Delivery, env, gate, files, data), deploy.sh runs tests/delivery.mjsmre
  • ab6331f4ident#7: tests/delivery.mjs — fake clock gate: Vienna/New York/Tokyo/UTC 17:00, urgent, mail off, restart, DST days, zone changemre
  • 7869f57bident#7: delivery — the daily mail at 17:00 in the user's zone (digests table, once per local day, test clock IDENT_TEST_CLOCK), urgent mailed at once, push hookmre
  • 371ef1b5ident#7: lib/mail.hl sendNotificationMail (sink: <sink>.mail, one JSON line per mail)mre
  • 39749e0bident#7: time zones through hl:time — server checks isZone, an account without a known zone reads as UTC, allAccountsmre
  • 7a54fe72mission brief 011mre
  • a6a874cdident mission 010: vendor hybriel 0f396652 (plugins + compose cache volume/tmpfs + deploy URL wait + report)mre
  • 4e7cf78emission brief 010mre
  • e8b2b0f7docker-compose: init: true (hybriel#156, PID 1 ignored SIGTERM, every restart waited 10 s)mre
  • 5fdbb6b2ident mission 009: report — scratch folder notemre
  • 74235815ident mission 009 (4/4): docs (README files map + same-output test, STATUS, LOG), report, tests/letcount.py + realdata-baseline/comparemre
  • fe183516ident mission 009 (3/4): let only where reassigned — 293 never-reassigned lets are plain declarations; kept: reassigned, loop bodies, names of a file member, a name declared twice in one function; same outputmre
  • d2e7f91bident mission 009 (2/4): one lib file per topic (login, accounts, identities, apps, invites, selector, notify + helpers, util), function routes as thin wrappers in lib/api.hl, project.hl = the map; same outputmre
  • 91017164ident mission 009 (1/4): file moves — the root .hl files into lib/ (api.hl → lib/api-helpers.hl), styles.hl → components/styles.hl; imports adjusted, no other changemre
  • f8bdcbc2ident: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); all gates greenmre