Files
thelounge/client/js/chan.ts
Max Leiter eb75c4b77c chore: refactor Mentions, add isIgnoredUser util (#5051)
- Mentions were doing a bunch of mutations; not just uses derived state
- no need for a separate `ClientMention` 
- added `extractInputHistory` for shared logic
- tests made by claude
2026-04-11 07:59:14 -07:00

31 lines
1.1 KiB
TypeScript

import {ClientChan, ClientMessage} from "./types";
import {SharedNetworkChan} from "../../shared/types/network";
import {SharedMsg} from "../../shared/types/msg";
import {ChanType} from "../../shared/types/chan";
import {extractInputHistory} from "./helpers/inputHistory";
export function toClientChan(shared: SharedNetworkChan): ClientChan {
const history: string[] = [""].concat(extractInputHistory(shared.messages, 99));
// filter the unused vars
const {messages, totalMessages: _, ...props} = shared;
const channel: ClientChan = {
...props,
editTopic: false,
pendingMessage: "",
inputHistoryPosition: 0,
historyLoading: false,
scrolledToBottom: true,
users: [],
usersOutdated: shared.type === ChanType.CHANNEL ? true : false,
moreHistoryAvailable: shared.totalMessages > shared.messages.length,
inputHistory: history,
messages: sharedMsgToClientMsg(messages),
};
return channel;
}
function sharedMsgToClientMsg(shared: SharedMsg[]): ClientMessage[] {
// TODO: this is a stub for now, we will want to populate client specific stuff here
return shared;
}