Skip to content

Commit

Permalink
use virtual list for activity events (#6675)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianjelfs authored Oct 24, 2024
1 parent 15b68e6 commit 954d4d5
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions frontend/app/src/components/home/activity/ActivityFeed.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
import Close from "svelte-material-icons/Close.svelte";
import BellRingOutline from "svelte-material-icons/BellRingOutline.svelte";
import { _ } from "svelte-i18n";
import { OpenChat, routeForMessage, type MessageActivityEvent } from "openchat-client";
import {
messageContextToString,
OpenChat,
routeForMessage,
type MessageActivityEvent,
} from "openchat-client";
import { getContext, onMount } from "svelte";
import SectionHeader from "../../SectionHeader.svelte";
import { iconSize } from "../../../stores/iconSize";
Expand All @@ -13,6 +18,7 @@
import { menuCloser } from "../../../actions/closeMenu";
import page from "page";
import ActivityEvent from "./ActivityEvent.svelte";
import VirtualList from "../../VirtualList.svelte";
const client = getContext<OpenChat>("client");
let selectedEvent: MessageActivityEvent | undefined = undefined;
Expand Down Expand Up @@ -44,6 +50,12 @@
selectedEvent = ev;
page(routeForMessage("none", ev.messageContext, ev.messageIndex));
}
function eventKey(event: MessageActivityEvent): string {
return `${messageContextToString(event.messageContext)}_${event.eventIndex}_${
event.activity
}`;
}
</script>

<SectionHeader slim border={false}>
Expand All @@ -63,12 +75,12 @@
</SectionHeader>

<div use:menuCloser class="body">
{#each activityEvents as event}
<VirtualList keyFn={eventKey} items={activityEvents} let:item>
<ActivityEvent
{event}
selected={selectedEvent === event}
on:click={() => selectEvent(event)} />
{/each}
event={item}
selected={selectedEvent === item}
on:click={() => selectEvent(item)} />
</VirtualList>
</div>

<style lang="scss">
Expand Down

0 comments on commit 954d4d5

Please sign in to comment.