Changeset 544e9c2 in Klonkt for src/views/pages/messages.ejs


Ignore:
Timestamp:
07/19/2026 11:58:47 PM (7 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
162c7a7
Parents:
8ed65a6
Message:

Feature: Messages "poll finished" notification (klonkt-demo-93o)

Closed own polls surface a poll_done item in Messages with the final tally (bar+pct per option, voter count), derived read-time from poll_json.closed via ownPollView. i18n msg.poll_done/msg.poll_total (NL/EN/DE). Tests in messages.test.js.

Co-Authored-By: Claude Opus 4.8 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/pages/messages.ejs

    r8ed65a6 r544e9c2  
    3232           // replies; Conversations = every other (public) reply.
    3333           var _kind = _t === 'sent' ? 'sent'
    34              : (_t === 'like' || _t === 'boost' || _t === 'follow') ? 'act'
     34             : (_t === 'like' || _t === 'boost' || _t === 'follow' || _t === 'poll_done') ? 'act'
    3535             : _t === 'report' ? 'mod'
    3636             : (_t === 'mention' || _priv0) ? 'msgs'
     
    4242          <span class="msg-av<%= _t === 'sent' ? ' msg-av-sent' : '' %>" aria-hidden="true">
    4343            <% if (_t === 'sent') { %><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>
     44            <% } else if (_t === 'poll_done') { %><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/></svg>
    4445            <% } else if (n.icon) { %><img src="<%= avatar(n.icon, 96) %>" alt="" loading="lazy">
    4546            <% } else { %><%= _init %><% } %>
     
    5152              <% } else if (_t === 'mention') { %><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>
    5253              <% } else if (_t === 'sent') { %><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 17 4 12 9 7"/><path d="M20 18v-2a4 4 0 0 0-4-4H4"/></svg>
     54              <% } else if (_t === 'poll_done') { %><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/></svg>
    5355              <% } else { %><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg><% } %>
    5456            </span>
     
    7880              <% } else if (_t === 'mention') { %><%= t('notif.mentioned') %>
    7981              <% } else if (_t === 'sent') { %><%= t('msg.sent_reply') %>
     82              <% } else if (_t === 'poll_done') { %><strong><%= t('msg.poll_done') %></strong>
    8083              <% } else { %><%= t('notif.replied') %><% } %>
    8184              <% if (_priv) { %><span class="msg-priv" title="<%= t('msg.private_hint') %>">🔒 <%= t('msg.private') %></span><% } %>
     
    8689
    8790            <% if (_t === 'report' && n.content) { %><div class="msg-content"><%= n.content %></div>
    88             <% } else if ((_t === 'reply' || _t === 'mention' || _t === 'sent') && n.content) { %><div class="msg-content"><%- n.content %></div><% } %>
     91            <% } else if ((_t === 'reply' || _t === 'mention' || _t === 'sent') && n.content) { %><div class="msg-content"><%- n.content %></div>
     92            <% } else if (_t === 'poll_done' && n.poll) { %>
     93              <div class="msg-poll" role="group">
     94                <% n.poll.options.forEach(function (o) { %>
     95                  <div class="msg-poll-opt">
     96                    <div class="msg-poll-top"><span class="msg-poll-name"><%= o.name %></span><span class="msg-poll-pct"><%= o.pct %>%</span></div>
     97                    <div class="msg-poll-bar"><span style="width:<%= o.pct %>%"></span></div>
     98                  </div>
     99                <% }); %>
     100                <div class="msg-poll-total"><%= t('msg.poll_total', { n: n.poll.voters }) %></div>
     101              </div>
     102            <% } %>
    89103
    90104            <% if (_t === 'sent' && n.outboxId) { %>
     
    143157    var body = li.querySelector('.msg-content');
    144158    var post = li.querySelector('.msg-post');
     159    var poll = li.querySelector('.msg-poll');
    145160    li._search = ((li.getAttribute('data-who') || '') + ' ' +
    146       (body ? body.textContent : '') + ' ' + (post ? post.textContent : '')).toLowerCase();
     161      (body ? body.textContent : '') + ' ' + (post ? post.textContent : '') + ' ' +
     162      (poll ? poll.textContent : '')).toLowerCase();
    147163  });
    148164  function apply() {
     
    232248  .msg-content p { margin: .2rem 0; } .msg-content p:first-child { margin-top: 0; } .msg-content p:last-child { margin-bottom: 0; }
    233249
     250  .msg-poll { margin: .5rem 0 0; display: flex; flex-direction: column; gap: .4rem; }
     251  .msg-poll-opt { display: flex; flex-direction: column; gap: .2rem; }
     252  .msg-poll-top { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; }
     253  .msg-poll-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
     254  .msg-poll-pct { font-variant-numeric: tabular-nums; color: var(--ink-soft, #888); flex-shrink: 0; }
     255  .msg-poll-bar { height: 7px; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--ink, #000) 10%, transparent); }
     256  .msg-poll-bar span { display: block; height: 100%; border-radius: 999px; background: var(--accent, #06c); }
     257  .msg-poll-total { font-size: .78rem; color: var(--ink-soft, #888); margin-top: .1rem; }
     258
    234259  .msg-actions { display: flex; gap: .7rem; align-items: center; margin-top: .45rem; }
    235260  .msg-edit summary { cursor: pointer; font-size: .8rem; color: var(--ink-soft, #888); font-weight: 600; }
Note: See TracChangeset for help on using the changeset viewer.