mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-28 22:31:22 -05:00
Fix key
This commit is contained in:
@@ -55,6 +55,7 @@ export function EventFeed({
|
||||
],
|
||||
R.sortBy([R.prop("t"), "desc"]),
|
||||
R.take(FEED_LENGTH),
|
||||
withUniqueKeys,
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -63,7 +64,7 @@ export function EventFeed({
|
||||
<li className={styles.empty}>Waiting for the first read…</li>
|
||||
) : (
|
||||
items.map((item) => (
|
||||
<li key={`${item.type}-${item.t}`} className={styles.item}>
|
||||
<li key={item.key} className={styles.item}>
|
||||
<span className={styles.icon}>
|
||||
<EventTypeIcon type={item.type} size={14} />
|
||||
</span>
|
||||
@@ -78,6 +79,17 @@ export function EventFeed({
|
||||
);
|
||||
}
|
||||
|
||||
/** `t` is whole seconds, so e.g. a double splat shares type and `t` */
|
||||
function withUniqueKeys(items: FeedItem[]) {
|
||||
const seen = new Map<string, number>();
|
||||
return items.map((item) => {
|
||||
const base = `${item.type}-${item.t}-${item.label}`;
|
||||
const count = seen.get(base) ?? 0;
|
||||
seen.set(base, count + 1);
|
||||
return { ...item, key: `${base}-${count}` };
|
||||
});
|
||||
}
|
||||
|
||||
function eventLabel(event: ScanEvent): string | null {
|
||||
switch (event.type) {
|
||||
case MAP_START_EVENT_TYPE: {
|
||||
|
||||
Reference in New Issue
Block a user