Skip to content

Commit

Permalink
Merge pull request #16 from Nikitosiki/dev
Browse files Browse the repository at this point in the history
Fix: load avatar and other
  • Loading branch information
Nikitosiki authored Dec 26, 2023
2 parents c8e9840 + ee005d5 commit 17e3f61
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 13 deletions.
7 changes: 5 additions & 2 deletions client/src/components/AddReactionButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ const AddReactionButton: FC<AddReactionProps> = ({ onClick, buttonProps }) => {
<DropdownTrigger>
<Button
size="sm"
className={buttonProps?.className ?? "h-7 w-7 min-w-0 rounded-full bg-default-200 text-sm"}
className={
buttonProps?.className ??
"h-7 w-7 min-w-0 rounded-full bg-default-200 text-sm"
}
{...buttonProps}
>
{buttonProps?.content ?? "+"}
Expand All @@ -46,7 +49,7 @@ const AddReactionButton: FC<AddReactionProps> = ({ onClick, buttonProps }) => {
selectedKeys={selectedKeys}
onSelectionChange={setSelectedKeys}
classNames={{
list: "flex-row flex-wrap",
list: "flex-row flex-wrap justify-between",
base: "max-w-[188px]",
}}
items={reactions}
Expand Down
13 changes: 4 additions & 9 deletions client/src/components/AddTag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ITag } from "src/interfaces";

type TypeAddTagProps = {
add(tag: ITag | string): void;
} & Omit<AutocompleteProps, "children">;
} & Pick<AutocompleteProps, "isDisabled">;

const AddTag: FC<TypeAddTagProps> = ({ add, ...props }) => {
const [inputValue, setInputValue] = useState<string>("");
Expand Down Expand Up @@ -44,21 +44,16 @@ const AddTag: FC<TypeAddTagProps> = ({ add, ...props }) => {
list.setFilterText(val);
setInputValue(val);
}}
onFocusChange={(isFocused) => console.log(isFocused)}
scrollShadowProps={{
isEnabled: false,
}}
isClearable={false}
maxLength={30}
{...props}
>
{(item) =>
"title" in item && typeof item.title === "string" ? (
<AutocompleteItem key={item.title}>{item.title}</AutocompleteItem>
) : (
<></>
)
}
{(item) => (
<AutocompleteItem key={item.id}>{item.title}</AutocompleteItem>
)}
</Autocomplete>
{inputValue.length > 1 && (
<motion.div
Expand Down
1 change: 1 addition & 0 deletions client/src/components/Author/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const Author: FC<TypeAuthorProps> = ({
isBordered
src={nullToUndefined(author.image_url)}
className="mr-2 h-7 w-7 shrink-0 text-tiny ring-primary"
imgProps={{referrerPolicy: "no-referrer"}}
{...rest}
/>
<div className="flex flex-col flex-nowrap overflow-hidden">
Expand Down
1 change: 1 addition & 0 deletions client/src/components/Comment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const Comment: FC<ICommentProps> = ({ comment, postId, user, children }) => {
size="sm"
name={comment.author.name}
src={nullToUndefined(comment.author.image_url)}
imgProps={{referrerPolicy: "no-referrer"}}
/>
</Link>
<div
Expand Down
4 changes: 3 additions & 1 deletion client/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export { useSwitchTheme } from "./useSwitchTheme";
export { useStateWindowSize } from "./useStateWindowSize"
export { useStateWindowSize } from "./useStateWindowSize";
export { useFingerprintData } from "./useFingerprintData";
export { useReload } from "./useReload";
13 changes: 13 additions & 0 deletions client/src/hooks/useReload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useCallback } from "react";
import { useLocation, useNavigate } from "react-router-dom";

export const useReload = () => {
const location = useLocation();
const navigate = useNavigate();

const reload = useCallback(() => {
navigate(location);
}, []);

return { reload };
};
1 change: 1 addition & 0 deletions client/src/modules/CardComments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const CardComments: FC<CardCommentsProps> = ({ fatherContent }) => {
size="sm"
name={user?.name}
src={user?.image_url ?? undefined}
imgProps={{referrerPolicy: "no-referrer"}}
/>
<Button
size="sm"
Expand Down
1 change: 1 addition & 0 deletions client/src/modules/Header/components/UserButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const UserButton = () => {
size={"sm"}
isBordered={true}
color={"primary"}
imgProps={{referrerPolicy: "no-referrer"}}
className="bg-default"
/>
<p className="hidden max-w-[20rem] truncate md:block md:max-w-[10rem] md:pl-4">
Expand Down
5 changes: 4 additions & 1 deletion client/src/modules/ProfileEditModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { yupResolver } from "@hookform/resolvers/yup";
import { useForm } from "react-hook-form";
import { ProfileSchema, ProfileSchemaType } from "src/validations";
import { updateUserById } from "src/services/supabase/user";
import { useReload } from "src/hooks";

type ProfileModalProps = Pick<UseDisclosureReturn, "isOpen" | "onOpenChange">;
const ProfileEditModal: FC<ProfileModalProps> = ({ isOpen, onOpenChange }) => {
Expand All @@ -26,6 +27,7 @@ const ProfileEditModal: FC<ProfileModalProps> = ({ isOpen, onOpenChange }) => {
const [isLoading, setIsLoading] = useState(false);

const { user } = useAuth();
const { reload } = useReload();

const {
register,
Expand Down Expand Up @@ -94,8 +96,8 @@ const ProfileEditModal: FC<ProfileModalProps> = ({ isOpen, onOpenChange }) => {
if (!user) return;
updateUserById(user?.id, submitData.name, verifImageUrl).then((response) => {
if (response) {
reload();
closeAuthModal();
location.reload();
}
});
};
Expand All @@ -121,6 +123,7 @@ const ProfileEditModal: FC<ProfileModalProps> = ({ isOpen, onOpenChange }) => {
isBordered
size="lg"
src={verifImageUrl ?? user.image_url ?? ""}
imgProps={{referrerPolicy: "no-referrer"}}
className="shrink-0 text-tiny ring-primary"
/>
<div className="flex flex-col flex-nowrap overflow-hidden">
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/Author/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const Author = () => {
isBlurred
radius="full"
src={author.image_url ?? ""}
referrerPolicy="no-referrer"
alt={(author.name ?? "Author's") + " avatar"}
classNames={{
blurredImg: "m-5",
Expand Down

0 comments on commit 17e3f61

Please sign in to comment.