~emersion/gamja

d19f127952025c658e996dfb4f836f830dc23640 — Simon Ser a day ago c05dcff
Move message key generation to State.addMessage
2 files changed, 4 insertions(+), 5 deletions(-)

M components/app.js
M state.js
M components/app.js => components/app.js +0 -5
@@ 45,8 45,6 @@ const configPromise = fetch("./config.json")

const CHATHISTORY_MAX_SIZE = 4000;

let messagesCount = 0;

function parseQueryString() {
	let query = window.location.search.substring(1);
	let params = {};


@@ 348,9 346,6 @@ export default class App extends Component {
	addMessage(serverID, bufName, msg) {
		let client = this.clients.get(serverID);

		msg.key = messagesCount;
		messagesCount++;

		msg.isHighlight = irc.isHighlight(msg, client.nick, client.cm);

		if (!msg.tags) {

M state.js => state.js +4 -0
@@ 136,6 136,7 @@ function insertMessage(list, msg) {

let lastServerID = 0;
let lastBufferID = 0;
let lastMessageKey = 0;

export const State = {
	updateServer(state, id, updater) {


@@ 391,6 392,9 @@ export const State = {
		}
	},
	addMessage(state, msg, bufID) {
		lastMessageKey++;
		msg.key = lastMessageKey;

		return State.updateBuffer(state, bufID, (buf) => {
			let messages = insertMessage(buf.messages, msg);
			return { messages };