Add room server

This commit is contained in:
Jack Kingsman
2026-03-19 19:22:40 -07:00
parent dbe2915635
commit 5b166c4b66
27 changed files with 1703 additions and 346 deletions
+13 -5
View File
@@ -3,18 +3,24 @@
*
* Uses the contact's public key to generate a consistent background color,
* and extracts initials or emoji from the name for display.
* Repeaters (type=2) always show 🛜 with a gray background.
* Repeaters (type=2) and room servers (type=3) always show a fixed glyph.
*/
import { CONTACT_TYPE_REPEATER } from '../types';
import { CONTACT_TYPE_REPEATER, CONTACT_TYPE_ROOM } from '../types';
// Repeater avatar styling
// Fixed contact-type avatar styling
const REPEATER_AVATAR = {
text: '🛜',
background: '#444444',
textColor: '#ffffff',
};
const ROOM_AVATAR = {
text: '🛖',
background: '#6b4f2a',
textColor: '#ffffff',
};
// DJB2 hash function for strings
export function hashString(str: string): number {
let hash = 0;
@@ -103,7 +109,7 @@ function getAvatarColor(publicKey: string): {
/**
* Get all avatar properties for a contact.
* Repeaters (type=2) always get a special gray avatar with 🛜.
* Repeaters and room servers always get a special fixed avatar.
*/
export function getContactAvatar(
name: string | null,
@@ -114,10 +120,12 @@ export function getContactAvatar(
background: string;
textColor: string;
} {
// Repeaters always get the repeater avatar
if (contactType === CONTACT_TYPE_REPEATER) {
return REPEATER_AVATAR;
}
if (contactType === CONTACT_TYPE_ROOM) {
return ROOM_AVATAR;
}
const text = getAvatarText(name, publicKey);
const colors = getAvatarColor(publicKey);
+3 -1
View File
@@ -15,7 +15,7 @@ const SIDEBAR_SECTION_SORT_ORDERS_KEY = 'remoteterm-sidebar-section-sort-orders'
export type ConversationTimes = Record<string, number>;
export type SortOrder = 'recent' | 'alpha';
export type SidebarSortableSection = 'favorites' | 'channels' | 'contacts' | 'repeaters';
export type SidebarSortableSection = 'favorites' | 'channels' | 'contacts' | 'rooms' | 'repeaters';
export type SidebarSectionSortOrders = Record<SidebarSortableSection, SortOrder>;
// In-memory cache of last message times (loaded from server on init)
@@ -116,6 +116,7 @@ export function buildSidebarSectionSortOrders(
favorites: defaultOrder,
channels: defaultOrder,
contacts: defaultOrder,
rooms: defaultOrder,
repeaters: defaultOrder,
};
}
@@ -133,6 +134,7 @@ export function loadLocalStorageSidebarSectionSortOrders(): SidebarSectionSortOr
favorites: parsed.favorites === 'alpha' ? 'alpha' : 'recent',
channels: parsed.channels === 'alpha' ? 'alpha' : 'recent',
contacts: parsed.contacts === 'alpha' ? 'alpha' : 'recent',
rooms: parsed.rooms === 'alpha' ? 'alpha' : 'recent',
repeaters: parsed.repeaters === 'alpha' ? 'alpha' : 'recent',
};
} catch {