+
-
+
-
+
@@ -95,11 +87,6 @@
- {#if $account && post.account.id === $account.id}
-
-
-
- {/if}
diff --git a/src/lib/ui/post/ReactionButton.svelte b/src/lib/ui/post/ReactionButton.svelte
index 6b933b1..fee3a97 100644
--- a/src/lib/ui/post/ReactionButton.svelte
+++ b/src/lib/ui/post/ReactionButton.svelte
@@ -1,5 +1,5 @@
@@ -49,7 +49,6 @@
border-radius: 8px;
transition: background-color .1s, color .1s;
cursor: pointer;
- border: 1px solid var(--bg-700);
}
button.active {
@@ -73,7 +72,7 @@
}
.icon {
- min-width: 20px;
+ width: 20px;
height: 20px;
display: flex;
justify-content: center;
diff --git a/src/lib/ui/post/ReplyContext.svelte b/src/lib/ui/post/ReplyContext.svelte
index 0474460..ad4f620 100644
--- a/src/lib/ui/post/ReplyContext.svelte
+++ b/src/lib/ui/post/ReplyContext.svelte
@@ -1,42 +1,39 @@
{#if post.reply}
- {#await post.reply then reply}
-
- {/await}
+
{/if}
{mouse_pos.left = e.pageX; mouse_pos.top = e.pageY}}
- on:mouseup={e => {if (e.pageX == mouse_pos.left && e.pageY == mouse_pos.top) gotoPost(e)}}
+ on:mousedown={e => {mouse_pos.left = e.pageX; mouse_pos.top = e.pageY; console.log(mouse_pos)}}
+ on:mouseup={e => {if (e.pageX == mouse_pos.left && e.pageY == mouse_pos.top) gotoPost()}}
on:keydown={gotoPost}>
@@ -46,9 +43,7 @@
diff --git a/src/lib/user/user.js b/src/lib/user/user.js
new file mode 100644
index 0000000..7b91fe8
--- /dev/null
+++ b/src/lib/user/user.js
@@ -0,0 +1,29 @@
+import { Client } from '../client/client.js';
+import { parseText as parseEmojis } from '../emoji.js';
+import { get } from 'svelte/store';
+
+export default class User {
+ id;
+ nickname;
+ username;
+ host;
+ avatar_url;
+ emojis;
+ url;
+
+ get name() {
+ return this.nickname || this.username;
+ }
+
+ get mention() {
+ let res = "@" + this.username;
+ if (this.host != get(Client.get()).instance.host)
+ res += "@" + this.host;
+ return res;
+ }
+
+ get rich_name() {
+ if (!this.nickname) return this.username;
+ return parseEmojis(this.nickname, this.host);
+ }
+}
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index aec6b96..9f7c10f 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -1,52 +1,21 @@
- {#if $notifications.length === 0}
-
- fetching notifications...
-
- {:else}
- {#each $notifications as notif}
-
- {/each}
- {/if}
-
-
-
diff --git a/src/routes/post/+page.js b/src/routes/post/+page.js
new file mode 100644
index 0000000..c0ac9bd
--- /dev/null
+++ b/src/routes/post/+page.js
@@ -0,0 +1,5 @@
+import { error } from '@sveltejs/kit';
+
+export function load(event) {
+ error(404, 'Not Found');
+}
diff --git a/src/routes/post/[id]/+page.js b/src/routes/post/[id]/+page.js
new file mode 100644
index 0000000..30569fd
--- /dev/null
+++ b/src/routes/post/[id]/+page.js
@@ -0,0 +1,39 @@
+import Post from '$lib/ui/post/Post.svelte';
+import { Client } from '$lib/client/client.js';
+import { parsePost } from '$lib/client/api.js';
+import { get } from 'svelte/store';
+import { goto } from '$app/navigation';
+
+export const ssr = false;
+
+export async function load({ params }) {
+ let client = get(Client.get());
+
+ if (!client.instance || !client.user) {
+ goto("/");
+ }
+
+ const post_id = params.id;
+
+ const post_data = await client.getPost(post_id);
+ if (!post_data) {
+ console.error(`Failed to retrieve post ${post_id}.`);
+ return null;
+ }
+
+ const post = await parsePost(post_data, 10, true);
+ let posts = [post];
+ for (let i in post.replies) {
+ const reply = post.replies[i];
+ // if (i > 1 && reply.reply_id === post.replies[i - 1].id) {
+ // let reply_head = posts.pop();
+ // reply.reply = reply_head;
+ // }
+ posts.push(reply);
+ // console.log(reply);
+ }
+
+ return {
+ posts: posts
+ };
+}
diff --git a/src/routes/post/[id]/+page.svelte b/src/routes/post/[id]/+page.svelte
new file mode 100644
index 0000000..a5e9edc
--- /dev/null
+++ b/src/routes/post/[id]/+page.svelte
@@ -0,0 +1,68 @@
+
+
+
+ {#if data.posts.length <= 0}
+
+ just a moment...
+
+ {:else}
+ {#key data}
+
+
+ {#each replies as post}
+
+ {/each}
+ {/key}
+ {/if}
+
+
+
diff --git a/svelte.config.js b/svelte.config.js
index 9c24c44..b371a21 100644
--- a/svelte.config.js
+++ b/svelte.config.js
@@ -17,11 +17,6 @@ const config = {
}),
version: {
name: child_process.execSync('git rev-parse HEAD').toString().trim()
- },
- alias: {
- '@cf/ui/*': "./src/lib/ui",
- '@cf/icons/*': "./src/img/icons",
- '@cf/store/*': "./src/lib/stores"
}
},
};