Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #158

Merged
merged 3 commits into from
Jul 2, 2024
Merged

fixes #158

Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/components/Post.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import ProfilePicture from './ProfilePicture.svelte';
import type { Comments } from '$lib/types/Comment';

export let postData;
export let postData: PostStructure;
export let currentUsername: string | undefined;

const toastStore = getToastStore();
Expand Down Expand Up @@ -147,15 +147,15 @@
async function setShowButton() {
showNoComments = !showNoComments;
if (showNoComments) {
commentData = await fetchComments(limit, postData.postId, offset);
commentData = (await fetchComments(limit, postData.postId, offset)) as Comments;
}
}

function commentSendButton() {
async function commentSendButton() {
sendComment(post.postId, commentText);
commentText = '';
click++;
commentData = fetchComments(limit, postData.postId, offset);
commentData = (await fetchComments(limit, postData.postId, offset)) as Comments;
}
</script>

Expand Down Expand Up @@ -253,6 +253,15 @@
</div>
</header>
<section class="p-4">
{#if post.repost.picture?.url}
<div class="flex justify-center">
<img
class="max-h-[375px] rounded-md object-contain"
src={post.repost.picture?.url}
alt=""
/>
</div>
{/if}
<p class="h-[10vh] p-1 text-lg" title="repostPostcontent">
{#each newRepostPost as { hashtagClass, text, wordID } (wordID)}
<span class="{hashtagClass} text-[0.75rem]">{text} </span>
Expand Down Expand Up @@ -297,7 +306,6 @@
title="commentInput"
bind:value={commentText}
placeholder={$t('post.postComment.placeholder')}
rows="1"
maxlength="128"
/>
</label>
Expand All @@ -310,7 +318,7 @@
</div>
{#if (loginToken != '' || loginToken == undefined) && showNoComments}
{#key click}
<Commentsection postId={post.postId} {commentData} />
<Commentsection postId={post.postId} commentData={commentData ?? 404} />
{/key}
{/if}
</main>
2 changes: 1 addition & 1 deletion src/components/layout/Navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
}
</script>

<AppBar class="fixed top-0 left-0 right-0">
<AppBar zIndex="9" class="fixed top-0 left-0 right-0">
<svelte:fragment slot="lead">
<div style="gap: 1rem; display: flex; align-items: center;">
<a href="/" on:click={play} on:keyup={play}>
Expand Down
7 changes: 2 additions & 5 deletions src/components/modals/ModalChat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
}
</script>

<div class="card w-[60vw] h-[80vh] p-2">
<div class="card w-[60vw] h-[75vh] p-2">
<header class="h-[7%] flex flex-row justify-between items-center mb-2">
<button class="btn-sm variant-filled-primary rounded" on:click={openModalBeginChat}>
{$t('chat.button.add')}
Expand Down Expand Up @@ -224,10 +224,7 @@
</section>
{/if}
<div class="border-t border-surface-500/30 p-4" hidden={messageDisabeled}>
<form
class="input-group input-group-divider flex-row flex rounded-container-token"
onclick={sendMessage}
>
<form class="input-group input-group-divider flex-row flex rounded-container-token">
<textarea
on:keypress={(event) => {
if (event.key === 'Enter') {
Expand Down
18 changes: 10 additions & 8 deletions src/components/popups/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { locale, t } from '../../i18n';
import { onMount } from 'svelte';
import { get } from 'svelte/store';
import { serverURL } from '$lib/Store';
import { serverURL, token } from '$lib/Store';
let language = '';
let server = get(serverURL);

Expand All @@ -27,11 +27,13 @@
<option value="de">{$t('settings.language.de')}</option>
</select>
<LightSwitch class="w-10 h-10 mt-2" />
<h5 class="h5 my-1">{$t('settings.server')}</h5>
<select value={server} on:input={changeServer} class="select" name="Server" id="Server">
<option value="https://alpha.c930.net/api">Server-alpha</option>
<option value="https://server-beta.de/api">Server-beta</option>
<option value="https://projekt-mockserver.mabu2807.de/api">Mockserver-Server</option>
<option value="http://localhost:3000/api">Mockserver-local</option>
</select>
{#if !$token}
<h5 class="h5 my-1">{$t('settings.server')}</h5>
<select value={server} on:input={changeServer} class="select" name="Server" id="Server">
<option value="https://alpha.c930.net/api">Server-alpha</option>
<option value="https://server-beta.de/api">Server-beta</option>
<option value="https://projekt-mockserver.mabu2807.de/api">Mockserver-Server</option>
<option value="http://localhost:3000/api">Mockserver-local</option>
</select>
{/if}
</main>
14 changes: 2 additions & 12 deletions src/lib/types/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { Picture } from './Pictures';

export type PostStructure = {
postId: UUID;
author: Author;
author: Author | undefined;
creationDate: string;
picture: Picture | undefined;
content: string;
Expand All @@ -22,18 +22,8 @@ export type TextColorPost = {
wordID: number;
};

export type PostUserProfilStructure = {
postId: UUID;
creationDate: string;
content: string;
picture: Picture | undefined;
likes: number;
liked: boolean;
location: GeoLocationCoords | undefined;
};

export type UserPostFetchResponse = {
records: PostUserProfilStructure[];
records: PostStructure[];
pagination: Pagination;
statusCode: number;
};
Expand Down
10 changes: 2 additions & 8 deletions src/lib/utils/Comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { get } from 'svelte/store';
import type { Comments } from '../types/Comment';
import type { UUID } from 'crypto';

export async function fetchComments(
limit: number,
postId: UUID,
offset: number
): Promise<Comments | number> {
export async function fetchComments(limit: number, postId: UUID, offset: number) {
let data: Comments = {
records: [],
pagination: {
Expand Down Expand Up @@ -40,9 +36,7 @@ export async function fetchComments(

if (response.status === 200) {
data = (await response.json()) as Comments;
return data;
} else {
return response.status;
return data as Comments;
}
}
export async function sendComment(postId: UUID, commentText: string) {
Expand Down
6 changes: 2 additions & 4 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@

<Toast zIndex="10" />
<Modal zIndex="8" components={modalRegistry} />
<AppShell zIndex="-1">
<AppShell>
<svelte:fragment slot="header"><Navbar /></svelte:fragment>
<slot />
<svelte:fragment slot="footer"
><div class="fixed left-0 bottom-0 right-0"><Footer /></div></svelte:fragment
>
<svelte:fragment slot="footer"><div class="w-screen"><Footer /></div></svelte:fragment>
</AppShell>
2 changes: 1 addition & 1 deletion src/routes/imprint/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
});
</script>

<main class="flex flex-col justify-center items-center mt-3 mb-[70px] mt-[90px]">
<main class="flex flex-col justify-center items-center mt-[90px]">
<div class="card bg-red p-2 w-[80vw] mb-5">
<h1 class="font-bold text-2xl">{$t('imprint.frontend.header')}</h1>
<div class="mt-2">
Expand Down
6 changes: 3 additions & 3 deletions src/routes/profile/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@

<Toast zIndex="1100" />
{#if profileData.statusCode == 200}
<main class=" flex flex-col items-center justify-start mb-[70px] mt-[90px]">
<main class=" flex flex-col items-center justify-start mt-[90px]">
<div
class=" w-full min-h-[35vh] flex flex-col md:flex-row justify-center items-center border-b-4 border-indigo-800"
>
Expand Down Expand Up @@ -283,8 +283,8 @@
<p class="text-2xl">{$t('profile.noPosts')}</p>
{:else}
<div class="flex flex-col items-center justify-start mt-3 mb-3 w-full">
{#each postsData.records as postData (postData.postId)}
<Post bind:postData currentUsername={usernameParams} />
{#each postsData.records as signlePostData (signlePostData.postId)}
mabu2807 marked this conversation as resolved.
Show resolved Hide resolved
<Post postData={signlePostData} currentUsername={usernameParams} />
{/each}
{#if postsData.records.length < postsData.pagination.records}
<button on:click={loadMorePosts} class="btn variant-filled"
Expand Down
2 changes: 1 addition & 1 deletion src/routes/profile/followers/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
});
</script>

<main class="flex flex-col items-center mt-16 min-h-[70vh] mb-[70px] mt-[90px]">
<main class="flex flex-col items-center min-h-[70vh] mt-[90px]">
<h2 class="h2 mb-10">{$t('profile.followers')}</h2>
<div class="mb-20">
{#if followerData.records.length == 0}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/profile/following/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
});
</script>

<main class="flex flex-col items-center mt-16 min-h-[70vh] mb-[70px] mt-[90px]">
<main class="flex flex-col items-center min-h-[70vh] mt-[90px]">
<h2 class="h2 mb-10">{$t('profile.following')}</h2>
<div class="mb-20">
{#if followingData.records.length == 0}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/register/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
</script>

<Toast />
<main class=" flex flex-col justify-center items-center h-[90vh] mb-[70px] mt-[90px]">
<main class=" flex flex-col justify-center items-center h-[90vh] mt-[90px]">
<div class="card lg:w-[40vw] md:w-[80vw] w-[95vw] h-[80vh] p-10">
<h1 class="h1 mb-14">{$t('register.header')}</h1>

Expand Down
2 changes: 1 addition & 1 deletion src/routes/search/posts/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</script>

<main>
<div class="mb-[122px] w-3/5 min-h-screen mx-auto mt-[122px]">
<div class="mb-8 w-3/5 min-h-screen mx-auto mt-[122px]">
<div class="mb-8 flex justify-center items-center gap-4">
<a href="/search/users">
<Icon class="w-10 h-10" icon="mdi:account-search-outline" style="font-size: 32px" />
Expand Down
2 changes: 1 addition & 1 deletion src/routes/search/users/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</script>

<Toast zIndex="1100" />
<div class="mt-8 w-3/5 min-h-screen mx-auto mb-[70px] mt-[122px]">
<div class=" w-3/5 min-h-screen mx-auto mt-[122px]">
<div class="mb-8 flex justify-center items-center gap-4">
<a href="/search/users" data-sveltekit-preload-data="hover">
<Icon
Expand Down
2 changes: 1 addition & 1 deletion src/routes/verify/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
$: formCorrectCode = verifyInput.length == 6;
</script>

<main class="flex justify-center items-center w-screen h-screen mb-[70px] mt-[90px]">
<main class="flex justify-center items-center w-screen h-screen mt-[90px]">
<div class="card lg:w-[40vw] md:w-[80vw] w-[95vw] h-[60vh] p-5">
<h2 class="h2">{$t('verify.header')}</h2>

Expand Down
Loading