finish URL rewrite, remove redundant logged_in state
This commit is contained in:
parent
a3fdd0007c
commit
4d771d8ebd
|
@ -1,4 +1,3 @@
|
|||
import { writable } from 'svelte/store';
|
||||
|
||||
export let account = writable(false);
|
||||
export let logged_in = writable(false);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import * as api from '$lib/api.js';
|
||||
import { account, logged_in } from '$lib/stores/account.js';
|
||||
import { account } from '$lib/stores/account.js';
|
||||
import { server } from '$lib/client/server.js';
|
||||
import { app } from '$lib/client/app.js';
|
||||
import { play_sound } from '$lib/sound.js';
|
||||
|
@ -8,7 +8,6 @@
|
|||
import { getNotifications } from '$lib/notifications.js';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { get } from 'svelte/store';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { unread_notif_count } from '$lib/notifications.js';
|
||||
|
||||
|
@ -32,7 +31,7 @@
|
|||
const dispatch = createEventDispatcher();
|
||||
|
||||
function handle_btn(name) {
|
||||
if (!get(logged_in)) return;
|
||||
if (!$account) return;
|
||||
let route;
|
||||
switch (name) {
|
||||
case "timeline":
|
||||
|
@ -63,16 +62,15 @@
|
|||
if (!confirm("This will log you out. Are you sure?")) return;
|
||||
|
||||
const res = await api.revokeToken(
|
||||
get(server).host,
|
||||
get(app).id,
|
||||
get(app).secret,
|
||||
get(app).token
|
||||
$server.host,
|
||||
$app.id,
|
||||
$app.secret,
|
||||
$app.token
|
||||
);
|
||||
|
||||
if (!res.ok)
|
||||
console.warn("Token revocation failed! Dumping data anyways");
|
||||
|
||||
logged_in.set(false);
|
||||
account.set(false);
|
||||
app.set(false);
|
||||
server.set(false);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<script>
|
||||
import * as api from '$lib/api.js';
|
||||
import { server } from '$lib/client/server';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
import ReplyIcon from '$lib/../img/icons/reply.svg';
|
||||
import RepostIcon from '$lib/../img/icons/repost.svg';
|
||||
import FavouriteIcon from '$lib/../img/icons/like.svg';
|
||||
import ReactIcon from '$lib/../img/icons/react.svg';
|
||||
import QuoteIcon from '$lib/../img/icons/quote.svg';
|
||||
// import QuoteIcon from '$lib/../img/icons/quote.svg';
|
||||
import ReactionBar from '$lib/ui/post/ReactionBar.svelte';
|
||||
import ActionBar from '$lib/ui/post/ActionBar.svelte';
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
|||
event.ctrlKey)) return;
|
||||
if (event.key && event.key !== "Enter") return;
|
||||
}
|
||||
goto(`/post/${data.status.id}`);
|
||||
goto(`/${$server.host}/${data.status.account.mention}/${data.status.id}`);
|
||||
}
|
||||
|
||||
let aria_label = function (data) {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<script>
|
||||
import { server } from '$lib/client/server';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
import PostHeader from './PostHeader.svelte';
|
||||
import Body from './Body.svelte';
|
||||
import Post from './Post.svelte';
|
||||
import ActionBar from './ActionBar.svelte';
|
||||
import ReactionBar from './ReactionBar.svelte';
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
|||
event.ctrlKey)) return;
|
||||
if (event.key && event.key !== "Enter") return;
|
||||
}
|
||||
goto(`/post/${post.id}`);
|
||||
goto(`/${$server.host}/${post.account.mention}/${post.id}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import * as api from '$lib/api.js';
|
||||
import { server } from '$lib/client/server.js';
|
||||
import { app } from '$lib/client/app.js';
|
||||
import { account, logged_in } from '$lib/stores/account.js';
|
||||
import { account } from '$lib/stores/account.js';
|
||||
import { parseAccount } from '$lib/account.js';
|
||||
import { unread_notif_count, last_read_notif_id } from '$lib/notifications.js';
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
|||
async function init() {
|
||||
if (!$app || !$app.token) {
|
||||
account.set(false);
|
||||
logged_in.set(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -26,7 +25,6 @@
|
|||
if (!data) return;
|
||||
|
||||
account.set(parseAccount(data));
|
||||
logged_in.set(true);
|
||||
console.log(`Logged in as @${$account.username}@${$account.host}`);
|
||||
|
||||
// spin up async task to fetch notifications
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<script>
|
||||
import { page } from '$app/stores';
|
||||
import { get } from 'svelte/store';
|
||||
import { account } from '$lib/stores/account.js';
|
||||
import { timeline, getTimeline } from '$lib/timeline.js';
|
||||
|
||||
|
@ -13,7 +12,7 @@
|
|||
});
|
||||
|
||||
document.addEventListener("scroll", () => {
|
||||
if (get(logged_in) && get(page).url.pathname !== "/") return;
|
||||
if ($account && $page.url.pathname !== "/") return;
|
||||
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 2048) {
|
||||
getTimeline();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import { app } from '$lib/client/app.js';
|
||||
import { parsePost } from '$lib/post.js';
|
||||
import { goto, afterNavigate } from '$app/navigation';
|
||||
import { base as previous_page } from '$app/paths'
|
||||
import { base } from '$app/paths'
|
||||
|
||||
import Post from '$lib/ui/post/Post.svelte';
|
||||
import Button from '$lib/ui/Button.svelte';
|
||||
|
@ -13,6 +13,7 @@
|
|||
|
||||
let post;
|
||||
let error = false;
|
||||
let previous_page = base;
|
||||
|
||||
if (($server && $server.host === data.server_host) && $app) {
|
||||
post = fetchPost(data.post_id, $app.token);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { goto } from '$app/navigation';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { unread_notif_count, last_read_notif_id } from '$lib/notifications.js';
|
||||
import { logged_in, account } from '$lib/stores/account.js';
|
||||
import { account } from '$lib/stores/account.js';
|
||||
|
||||
export let data;
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
|||
if (!data) return goto("/");
|
||||
|
||||
account.set(parseAccount(data));
|
||||
logged_in.set(true);
|
||||
console.log(`Logged in as @${get(account).username}@${get(account).host}`);
|
||||
|
||||
// spin up async task to fetch notifications
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
<script>
|
||||
import { notifications, getNotifications } from '$lib/notifications.js';
|
||||
import { logged_in } from '$lib/stores/account.js';
|
||||
import { account } from '$lib/stores/account.js';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { get } from 'svelte/store';
|
||||
import Notification from '$lib/ui/Notification.svelte';
|
||||
|
||||
if (!get(logged_in)) goto("/");
|
||||
if (!$account) goto("/");
|
||||
|
||||
getNotifications();
|
||||
document.addEventListener("scroll", event => {
|
||||
if (get(logged_in) && get(page).url.pathname !== "/notifications") return;
|
||||
document.addEventListener("scroll", () => {
|
||||
if ($account && $page.url.pathname !== "/notifications") return;
|
||||
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 2048) {
|
||||
getNotifications();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue