diff --git a/CHANGELOGS.md b/CHANGELOGS.md deleted file mode 100644 index 4c81497..0000000 --- a/CHANGELOGS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Campfire v0.3.0 -- Added notifications view -- Many more background tweaks, fixes, and optimisations - -# Campfire v0.2.0 -- Complete UI overhaul (thanks mae!) -- Added light and dark themes -- Added ability to like and boost posts -- Added ability to view threads in context -- Many background tweaks, fixes, and optimisations diff --git a/package-lock.json b/package-lock.json index 68c3b16..456763b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "campfire-client", - "version": "0.3.0", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "campfire-client", - "version": "0.3.0", + "version": "0.2.0", "license": "GPL-3.0", "devDependencies": { "@poppanator/sveltekit-svg": "^4.2.1", diff --git a/package.json b/package.json index 301641e..80a43c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "campfire-client", - "version": "0.3.0", + "version": "0.2.0", "description": "social media for the galaxy-wide-web! 🌌", "private": true, "type": "module", diff --git a/src/lib/client/api.js b/src/lib/client/api.js index 09e6514..c3accbb 100644 --- a/src/lib/client/api.js +++ b/src/lib/client/api.js @@ -1,9 +1,8 @@ -import { client } from '$lib/client/client.js'; -import { user } from '$lib/stores/user.js'; +import { client } from '../client/client.js'; import { capabilities } from '../client/instance.js'; -import Post from '$lib/post.js'; -import User from '$lib/user/user.js'; -import Emoji from '$lib/emoji.js'; +import Post from '../post.js'; +import User from '../user/user.js'; +import Emoji from '../emoji.js'; import { get } from 'svelte/store'; export async function createApp(host) { @@ -93,7 +92,7 @@ export async function verifyCredentials() { } export async function getNotifications(since_id, limit, types) { - if (!get(user)) return false; + if (!get(client).user) return false; let url = `https://${get(client).instance.host}/api/v1/notifications`; @@ -113,7 +112,6 @@ export async function getNotifications(since_id, limit, types) { } export async function getTimeline(last_post_id) { - if (!get(user)) return false; let url = `https://${get(client).instance.host}/api/v1/timelines/home`; if (last_post_id) url += "?max_id=" + last_post_id; const data = await fetch(url, { diff --git a/src/lib/client/client.js b/src/lib/client/client.js index e6d79ac..3ac4269 100644 --- a/src/lib/client/client.js +++ b/src/lib/client/client.js @@ -2,7 +2,7 @@ import { Instance, server_types } from './instance.js'; import * as api from './api.js'; import { get, writable } from 'svelte/store'; import { last_read_notif_id } from '$lib/notifications.js'; -import { user, logged_in } from '$lib/stores/user.js'; +import { user } from '$lib/stores/user.js'; export const client = writable(false); @@ -206,7 +206,6 @@ export class Client { console.warn("Failed to log out correctly; ditching the old tokens anyways."); } localStorage.removeItem(save_name); - logged_in.set(false); client.set(new Client()); console.log("Logged out successfully."); } diff --git a/src/lib/notifications.js b/src/lib/notifications.js index bbdc69f..5d16795 100644 --- a/src/lib/notifications.js +++ b/src/lib/notifications.js @@ -29,7 +29,7 @@ export async function getNotifications() { } } } - notif.status = notif.status ? await api.parsePost(notif.status, 0, false) : null; + notif.status = await api.parsePost(notif.status, 0, false); notifications.update(notifications => [...notifications, notif]); } last_read_notif_id.set(data[0].id); diff --git a/src/lib/stores/user.js b/src/lib/stores/user.js index fb9c2c4..6648031 100644 --- a/src/lib/stores/user.js +++ b/src/lib/stores/user.js @@ -1,22 +1,4 @@ -import { client } from '$lib/client/client.js'; -import * as api from '$lib/client/api.js'; -import { get, writable } from 'svelte/store'; +import { writable } from 'svelte/store'; export let user = writable(0); export let logged_in = writable(false); - -export async function getUser() { - // already known - if (get(user)) return get(user); - - // cannot provide- not logged in - if (!get(client).app || !get(client).app.token) return false; - - // logged in- attempt to retrieve using token - const data = await api.verifyCredentials(); - if (!data) return false; - - user.set(await api.parseUser(data)); - console.log(`Logged in as @${get(user).username}@${get(user).host}`); - return get(user); -} diff --git a/src/lib/ui/Navigation.svelte b/src/lib/ui/Navigation.svelte index c4ce6e5..4c8344b 100644 --- a/src/lib/ui/Navigation.svelte +++ b/src/lib/ui/Navigation.svelte @@ -3,7 +3,6 @@ import Button from './Button.svelte'; import Feed from './Feed.svelte'; import { client } from '$lib/client/client.js'; - import { user } from '$lib/stores/user.js'; import { play_sound } from '$lib/sound.js'; import { getTimeline } from '$lib/timeline.js'; import { getNotifications } from '$lib/notifications.js'; @@ -151,11 +150,11 @@
- play_sound()}> + play_sound()}>
diff --git a/src/lib/ui/Notification.svelte b/src/lib/ui/Notification.svelte index 58427c6..dd29e6f 100644 --- a/src/lib/ui/Notification.svelte +++ b/src/lib/ui/Notification.svelte @@ -48,7 +48,7 @@ } - +
{#if data.type === "favourite"} @@ -92,7 +92,7 @@