@frode
[26/85]
Considering rewriting micronotal in SvelteKit... I'm not a frontend developer by any means, and React's useEffect, useCallback, etc. keeps throwing me for a loop. SvelteKit seems to me to be more straightforward, and reactive values/statements are easier to understand when you have automatic dependency detection. As I have barely any experience with any frontend frameworks, I might of course be entirely wrong, and moving to SvelteKit won't magically provide a better developer experience. Pretty sure I'm going to go through with it, though.
So, the rewrite is underway. I've implemented auth, moved some pages and routes around to make things cleaner, and got a frontpage full of threads rendering almost identically to the Next.js implementation. Still a couple of pages left to go before I'm done.
Didn’t get much further today, but I have to say: SvelteKit is so far a much more pleasant experience than Next.js. Way easier to understand what happens client side and what happens server side. Data fetching is a breeze. Automatic typing of load functions. And everything is way snappier! The list goes on.
Writing this from the preview deployment of micronotal written in SvelteKit. Have to say, I'm blown away by how easy SK is to work with compared to Next.
Looking through things, I see that I've got some broken links to profiles now, but that's an easy fix
Adding to the todo-list: * I really should add a max length to post content * I’m also thinking I should do something about the display of posts with a large number of newlines, but that’s a lot trickier to get right. I don’t want to limit creativity; I think posts should be allowed to contain whatever formatting you want, but it can be detrimental to the user experience if posts and threads can offset others by just containing a ton of whitespace.
One possible solution that allows whatever post content you want is crowd-sourced moderation through votes. At scale, this can become an unwieldy tool requiring safeguards against vote manipulation.
Perhaps disabling email login and only supporting social login is part of the answer to prevent botting. Essentially piggybacking on the abuse prevention systems of the large companies.
Unrelated, but also on the todo-list: * use nextjs route groups to deduplicate some layout code
Updated favicon.ico, woo! Current todo-list: * SSR single-thread pages * Decrease horizontal padding on small screens
Done and done ✓
Still zooming in on textarea focus on small screens, will have to investigate other options. Maybe a different max width?
Summer salad: - 1/4 watermelon, diced - 1 pomegranate - feta cheese, diced - handful of cherry tomatoes - handful of basil leaves - handful of mint leaves - baby leaf greens - olive oil, salt, pepper to taste
New day, new thread. On todays todo-list: - get fragment links to work - truncate post and thread ids - clear post text area on submit - create a seed.sql to improve local dev
Thread/post IDs are now truncated, and the post elements have gotten id attributes that make scrolling kind of work. The issue is that the div with the fragment id is not present on page load, but is loaded in afterwards. Will have to think a bit more on how to solve it, leaving it for now.
Text area should now be cleared on submit. I've also added a check to the database disallowing empty posts, as well as aborting post submission in the frontend if textarea is empty. Only thing remaining is to create a little seed data (hello chatGPT)
After a chat with GPT-4 I now have a bunch of data available for seeding my local database. Doing so also revealed an issue with my RLS, where a user can add posts to a thread started by a different author. I also had an incorrect check in the frontend, where the textarea input was shown as long as you had a session. It's now only displayed if the logged in user is the same as the author of the thread.
RLS issue should be resolved now
made a couple more improvements: - return a helpful message instead of exploding if you look up a thread that doesn't exist - improve username constraints + set reasonable, semi-random username on creation - user deletion qol improvements
I believe the solution to the scrolling-to-fragment issue is to ssr the single-thread pages. Will try it out when I get the time.
Also on the todo-list: decrease horizontal padding on small screens in order to avoid 'zooming in' when text area is selected
First post, this is actually live and working
After a bit of fiddling with supabase complaining that a foreign key relation didn't exist, it's now _actually_ working. I was able to fix the issue by running NOTIFY pgrst, 'reload schema';
Having some issues with timestamps overflowing and covering author and thread ID on small screens, will fix tomorrow. Possible fix: only display timestamps on posts, not threads
Posts now display timestamps + id, and the post id is also a fragment link. Need to set the post id to truncate. Maybe just display the first section of the uuid? For the fragments to work I need to figure out how to do names anchors in react
One more thing I just noticed: need to clear the text area on submit