From 09388c5effcd9ac9df134bba2484f3fb9ae3bb68 Mon Sep 17 00:00:00 2001
From: Florian <45694132+flo-bit@users.noreply.github.com>
Date: Wed, 4 Jun 2025 15:42:30 +0200
Subject: [PATCH] switch to ids in timeline, removes old spaces
---
package-lock.json | 38 +++++-
package.json | 1 +
src/lib/SpaceSelection.svelte | 2 +-
src/lib/components/ChannelButton.svelte | 20 +++-
src/lib/components/ChatMessage.svelte | 110 +++++++++++-------
src/lib/components/ChatMessageThread.svelte | 19 ++-
src/lib/components/Image.svelte | 43 +++++--
src/lib/components/ReplyMessage.svelte | 2 +-
src/lib/components/SpaceItem.svelte | 14 ++-
src/lib/components/ThreadButton.svelte | 15 ++-
src/lib/components/TimelineView.svelte | 16 +--
src/lib/schema.ts | 12 +-
src/lib/utils.ts | 30 ++++-
src/routes/+page.svelte | 24 +++-
src/routes/[spaceId]/+layout.svelte | 6 +-
.../channel/[channelId]/+page.svelte | 71 ++++-------
.../thread/[threadId]/+page.svelte | 34 +-----
17 files changed, 294 insertions(+), 163 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index dcfb55e..7af4e3f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -30,6 +30,7 @@
"jazz-svelte": "^0.14.4",
"jazz-tools": "^0.14.4",
"paper": "^0.12.18",
+ "runed": "^0.28.0",
"svelte-relative-time": "^0.0.6",
"svelte-tiptap": "^2.1.0",
"virtua": "^0.41.2",
@@ -3075,6 +3076,21 @@
"svelte": "^5.11.0"
}
},
+ "node_modules/bits-ui/node_modules/runed": {
+ "version": "0.23.4",
+ "resolved": "https://registry.npmjs.org/runed/-/runed-0.23.4.tgz",
+ "integrity": "sha512-9q8oUiBYeXIDLWNK5DfCWlkL0EW3oGbk845VdKlPeia28l751VpfesaB/+7pI6rnbx1I6rqoZ2fZxptOJLxILA==",
+ "funding": [
+ "https://github.com/sponsors/huntabyte",
+ "https://github.com/sponsors/tglide"
+ ],
+ "dependencies": {
+ "esm-env": "^1.0.0"
+ },
+ "peerDependencies": {
+ "svelte": "^5.7.0"
+ }
+ },
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@@ -5759,13 +5775,14 @@
}
},
"node_modules/runed": {
- "version": "0.23.4",
- "resolved": "https://registry.npmjs.org/runed/-/runed-0.23.4.tgz",
- "integrity": "sha512-9q8oUiBYeXIDLWNK5DfCWlkL0EW3oGbk845VdKlPeia28l751VpfesaB/+7pI6rnbx1I6rqoZ2fZxptOJLxILA==",
+ "version": "0.28.0",
+ "resolved": "https://registry.npmjs.org/runed/-/runed-0.28.0.tgz",
+ "integrity": "sha512-k2xx7RuO9hWcdd9f+8JoBeqWtYrm5CALfgpkg2YDB80ds/QE4w0qqu34A7fqiAwiBBSBQOid7TLxwxVC27ymWQ==",
"funding": [
"https://github.com/sponsors/huntabyte",
"https://github.com/sponsors/tglide"
],
+ "license": "MIT",
"dependencies": {
"esm-env": "^1.0.0"
},
@@ -6145,6 +6162,21 @@
"svelte": "^5.0.0"
}
},
+ "node_modules/svelte-toolbelt/node_modules/runed": {
+ "version": "0.23.4",
+ "resolved": "https://registry.npmjs.org/runed/-/runed-0.23.4.tgz",
+ "integrity": "sha512-9q8oUiBYeXIDLWNK5DfCWlkL0EW3oGbk845VdKlPeia28l751VpfesaB/+7pI6rnbx1I6rqoZ2fZxptOJLxILA==",
+ "funding": [
+ "https://github.com/sponsors/huntabyte",
+ "https://github.com/sponsors/tglide"
+ ],
+ "dependencies": {
+ "esm-env": "^1.0.0"
+ },
+ "peerDependencies": {
+ "svelte": "^5.7.0"
+ }
+ },
"node_modules/tabbable": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.2.0.tgz",
diff --git a/package.json b/package.json
index 9a852a8..dfc5d9f 100644
--- a/package.json
+++ b/package.json
@@ -58,6 +58,7 @@
"jazz-svelte": "^0.14.4",
"jazz-tools": "^0.14.4",
"paper": "^0.12.18",
+ "runed": "^0.28.0",
"svelte-relative-time": "^0.0.6",
"svelte-tiptap": "^2.1.0",
"virtua": "^0.41.2",
diff --git a/src/lib/SpaceSelection.svelte b/src/lib/SpaceSelection.svelte
index 0fdb18a..1ef8699 100644
--- a/src/lib/SpaceSelection.svelte
+++ b/src/lib/SpaceSelection.svelte
@@ -74,7 +74,7 @@
{@const θ = i * angularWidth}
import { base } from '$app/paths';
import { page } from '$app/state';
- import { Channel } from '$lib/schema';
+ import { Channel, Message } from '$lib/schema';
import { Button } from '@fuxui/base';
import type { Loaded } from 'jazz-tools';
import { useCurrentRoute } from '$lib/context';
- import { afterNavigate } from '$app/navigation';
+ import { afterNavigate, goto } from '$app/navigation';
+ import { CoState } from 'jazz-svelte';
const route = useCurrentRoute();
@@ -19,10 +20,20 @@
onclick?: () => void;
} = $props();
+ let lastMessage = $derived(
+ new CoState(Message, channel.mainThread?.timeline?.at(-1), {
+ resolve: {
+ content: true,
+ images: true,
+ reactions: true
+ }
+ })
+ );
+
let isNew = $derived.by(() => {
if (!lastReadDate) return channel.mainThread?.timeline?.length !== 0;
if (!channel.mainThread?.timeline) return false;
- let date = channel.mainThread.timeline[channel.mainThread.timeline.length - 1]?.createdAt;
+ let date = lastMessage?.current?.createdAt;
if (!date) return false;
return new Date(lastReadDate) < date;
@@ -35,6 +46,9 @@
href="/{route.spaceId}/channel/{channel.id}"
class="relative w-full justify-start backdrop-blur-none"
{onclick}
+ onmousedown={() => {
+ goto(`/${route.spaceId}/channel/${channel.id}`);
+ }}
>