refactor: remove voting system, add author colors + pin numbering

- Remove votes backend (route, db functions, server mount)
- Remove votes frontend (store, socket, PinOverlay badges, FeedbackPanel UI)
- Add authorColors utility (8-color palette, deterministic hash)
- Add getPinNumber() to annotationStore
- Fix JWT to include username/display_name
- Add resolveAuthorName DB fallback for old tokens
This commit is contained in:
Hiren Kangad
2026-03-11 00:54:48 +05:30
parent f7a39a1726
commit f24414e25c
11 changed files with 60 additions and 200 deletions
+35
View File
@@ -0,0 +1,35 @@
const AUTHOR_COLORS = [
'#4a9eff', // blue
'#f97316', // orange
'#22c55e', // green
'#a855f7', // purple
'#ef4444', // red
'#06b6d4', // cyan
'#eab308', // yellow
'#ec4899', // pink
];
const AUTHOR_COLORS_HEX = [
0x4a9eff, 0xf97316, 0x22c55e, 0xa855f7,
0xef4444, 0x06b6d4, 0xeab308, 0xec4899,
];
function hashCode(str: string): number {
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0;
}
return Math.abs(hash);
}
export function getAuthorColor(userId: string): string {
return AUTHOR_COLORS[hashCode(userId) % AUTHOR_COLORS.length];
}
export function getAuthorColorHex(userId: string): number {
return AUTHOR_COLORS_HEX[hashCode(userId) % AUTHOR_COLORS_HEX.length];
}
export function getAuthorInitial(name: string): string {
return (name || '?').charAt(0).toUpperCase();
}