minor refactors and additional logs

This commit is contained in:
Max Nuding 2024-09-24 14:47:50 +02:00
parent 498b1d82d9
commit d39ccba927
No known key found for this signature in database
4 changed files with 25 additions and 10 deletions

View File

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
@ -54,9 +54,22 @@
color: var(--color-text); color: var(--color-text);
background-color: var(--color-bg); background-color: var(--color-bg);
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, font-family:
Ubuntu, Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif, 'Apple Color Emoji', system-ui,
'Segoe UI Emoji', 'Segoe UI Symbol'; -apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen-Sans,
Ubuntu,
Cantarell,
'Helvetica Neue',
Helvetica,
Arial,
sans-serif,
'Apple Color Emoji',
'Segoe UI Emoji',
'Segoe UI Symbol';
} }
a { a {

View File

@ -1,9 +1,10 @@
import { log } from '$lib/log'; import { log } from '$lib/log';
import { TimelineReader } from '$lib/server/timeline'; import { TimelineReader } from '$lib/server/timeline';
import type { HandleServerError } from '@sveltejs/kit'; import type { Handle, HandleServerError } from '@sveltejs/kit';
import { error } from '@sveltejs/kit'; import { error } from '@sveltejs/kit';
import fs from 'fs/promises'; import fs from 'fs/promises';
log.log('App startup');
TimelineReader.init(); TimelineReader.init();
export const handleError = (({ error }) => { export const handleError = (({ error }) => {
@ -16,8 +17,6 @@ export const handleError = (({ error }) => {
}; };
}) satisfies HandleServerError; }) satisfies HandleServerError;
import type { Handle } from '@sveltejs/kit';
export const handle = (async ({ event, resolve }) => { export const handle = (async ({ event, resolve }) => {
// Reeder *insists* on checking /feed instead of /feed.xml // Reeder *insists* on checking /feed instead of /feed.xml
if (event.url.pathname === '/feed') { if (event.url.pathname === '/feed') {

View File

@ -479,11 +479,11 @@ function saveSongInfoData(postUrl: string, songs: SongInfo[]): Promise<void> {
} }
export async function savePost(post: Post, songs: SongInfo[]) { export async function savePost(post: Post, songs: SongInfo[]) {
log.debug(`Saving post ${post.url}`);
if (!databaseReady) { if (!databaseReady) {
await waitReady(); await waitReady();
} }
log.debug(`Saving post ${post.url}`);
const account = post.account; const account = post.account;
await saveAccountData(account); await saveAccountData(account);
log.debug(`Saved account data ${post.url}`); log.debug(`Saved account data ${post.url}`);

View File

@ -224,7 +224,7 @@ export class TimelineReader {
accountUrl: accountUrl, accountUrl: accountUrl,
file: fn, file: fn,
sizeDescriptor: `${i}x` sizeDescriptor: `${i}x`
} as AccountAvatar) }) as AccountAvatar
) )
.then(saveAvatar) .then(saveAvatar)
) )
@ -261,7 +261,7 @@ export class TimelineReader {
file: fn, file: fn,
sizeDescriptor: `${i}x`, sizeDescriptor: `${i}x`,
kind: kind kind: kind
} as SongThumbnailImage) }) as SongThumbnailImage
) )
.then(saveSongThumbnail) .then(saveSongThumbnail)
) )
@ -363,6 +363,7 @@ export class TimelineReader {
try { try {
const data: TimelineEvent = JSON.parse(event.data.toString()); const data: TimelineEvent = JSON.parse(event.data.toString());
if (data.event !== 'update') { if (data.event !== 'update') {
log.log('Ignoring ES event', data.event);
return; return;
} }
const post: Post = JSON.parse(data.payload); const post: Post = JSON.parse(data.payload);
@ -410,10 +411,12 @@ export class TimelineReader {
} }
private constructor() { private constructor() {
log.log('Constructing timeline object');
this.startWebsocket(); this.startWebsocket();
} }
public static init() { public static init() {
log.log('Timeline object init');
if (this._instance === undefined) { if (this._instance === undefined) {
this._instance = new TimelineReader(); this._instance = new TimelineReader();
} }