<%- include('../partials/fedi-tabs', { active: 'connect' }) %>
<%= t('tl.connect') %>
<% if (typeof success !== 'undefined' && success) { %>
<%= success %>
<% } %>
<% if (typeof error !== 'undefined' && error) { %>
<%= error %>
<% } %>
<%
var conns = connections || [];
var reachable = conns.filter(function (c) { return !c.unreachable; });
var unreachable = conns.filter(function (c) { return c.unreachable; });
// Display fields for one connection: name/handle (fallback: derive from actor_uri).
function connView(c) {
var host = '', user = '';
try { var u = new URL(c.actor_uri); host = u.hostname; user = (u.pathname.split('/').filter(Boolean).pop() || ''); } catch (e) {}
var handle = c.handle || (user ? ('@' + user + '@' + host) : c.actor_uri);
var display = c.name || handle;
return { handle: handle, display: display,
initial: String(display || '?').replace(/^@/, '').charAt(0).toUpperCase(),
profileUrl: c.url || c.actor_uri };
}
function arrow(dir) { return dir === 'mutual' ? '↔' : (dir === 'following' ? '→' : '←'); }
%>
<% if (reachable.length) { %>
<% reachable.forEach(function (c) { var v = connView(c); %>
-
<% if (c.icon) { %>
<% } else { %><%= v.initial %><% } %>
<%= v.display %>
<%= arrow(c.direction) %> <%= t('tl.dir_' + c.direction) %>
<% if (c.follower && c.last_delivery_at) { %>· <%= t('tl.last_delivery') %>: <%= formatDateTime(c.last_delivery_at) %><% } %>
<% if (c.following) { %>
<% } %>
<% }); %>
<% } else { %>
<%= t('tl.connect_empty') %>
<% } %>
<% if (unreachable.length) { %>
⚠ <%= t('tl.unreachable') %> (<%= unreachable.length %>)
<%= t('tl.unreachable_lead') %>
<% unreachable.forEach(function (c) { var v = connView(c); %>
-
<% if (c.icon) { %>
<% } else { %><%= v.initial %><% } %>
<%= v.display %>
<%= arrow(c.direction) %> <%= t('tl.dir_' + c.direction) %>
<% if (c.last_delivery_at) { %>· <%= t('tl.last_delivery') %>: <%= formatDateTime(c.last_delivery_at) %><% } else { %>· <%= t('tl.never_delivered') %><% } %>
<% if (c.last_error_at) { %>· <%= t('tl.delivery_failed') %>: <%= formatDateTime(c.last_error_at) %><% } %>
<% if (c.follower_id) { %>
<% } %>
<% }); %>
<% } %>