cleanup
This commit is contained in:
@@ -5,7 +5,7 @@ import LikeIcon from "~/components/icons/LikeIcon";
|
||||
export interface PostLike {
|
||||
id: number;
|
||||
user_id: string;
|
||||
post_id: string;
|
||||
post_id: number;
|
||||
}
|
||||
|
||||
export interface AuthenticatedLikeProps {
|
||||
@@ -36,15 +36,15 @@ export default function AuthenticatedLike(props: AuthenticatedLikeProps) {
|
||||
if (initialHasLiked) {
|
||||
const result = await api.database.removePostLike.mutate({
|
||||
user_id: props.currentUserID,
|
||||
post_id: props.projectID.toString()
|
||||
post_id: props.projectID
|
||||
});
|
||||
setLikes(result.newLikes as PostLike[]);
|
||||
setLikes(result.newLikes as unknown as PostLike[]);
|
||||
} else {
|
||||
const result = await api.database.addPostLike.mutate({
|
||||
user_id: props.currentUserID,
|
||||
post_id: props.projectID.toString()
|
||||
post_id: props.projectID
|
||||
});
|
||||
setLikes(result.newLikes as PostLike[]);
|
||||
setLikes(result.newLikes as unknown as PostLike[]);
|
||||
}
|
||||
setInstantOffset(0);
|
||||
} catch (error) {
|
||||
|
||||
@@ -6,7 +6,8 @@ import type {
|
||||
UserPublicData,
|
||||
ReactionType,
|
||||
ModificationType,
|
||||
SortingMode
|
||||
SortingMode,
|
||||
CommentSectionProps
|
||||
} from "~/types/comment";
|
||||
import CommentInputBlock from "./CommentInputBlock";
|
||||
import CommentSortingSelect from "./CommentSortingSelect";
|
||||
|
||||
@@ -20,6 +20,7 @@ export default function DeletePostButton(props: DeletePostButtonProps) {
|
||||
await api.database.deletePost.mutate({ id: props.postID });
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
console.error("Failed to delete post:", error);
|
||||
alert("Failed to delete post");
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -271,11 +271,12 @@ export default function PostBodyClient(props: PostBodyClientProps) {
|
||||
const headings = contentRef.querySelectorAll<HTMLElement>("h2");
|
||||
let referencesSection: HTMLElement | null = null;
|
||||
|
||||
headings.forEach((heading) => {
|
||||
for (const heading of headings) {
|
||||
if (heading.textContent?.trim() === referencesHeadingText) {
|
||||
referencesSection = heading;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (referencesSection) {
|
||||
referencesSection.className = "text-2xl font-bold mb-4 text-text";
|
||||
@@ -285,7 +286,7 @@ export default function PostBodyClient(props: PostBodyClientProps) {
|
||||
parentDiv.classList.add("references-heading");
|
||||
}
|
||||
|
||||
let currentElement = referencesSection.nextElementSibling;
|
||||
let currentElement: Element | null = referencesSection.nextElementSibling;
|
||||
|
||||
while (currentElement) {
|
||||
if (currentElement.tagName === "P") {
|
||||
|
||||
@@ -22,7 +22,7 @@ interface PostFormProps {
|
||||
published: boolean;
|
||||
tags: string[];
|
||||
};
|
||||
userID: number;
|
||||
userID: string;
|
||||
}
|
||||
|
||||
export default function PostForm(props: PostFormProps) {
|
||||
@@ -89,7 +89,7 @@ export default function PostForm(props: PostFormProps) {
|
||||
tags: null,
|
||||
author_id: props.userID
|
||||
});
|
||||
const newId = result.data as number;
|
||||
const newId = Number(result.data);
|
||||
setCreatedPostId(newId);
|
||||
setHasSaved(true);
|
||||
return newId;
|
||||
|
||||
Reference in New Issue
Block a user