Skip to content

Commit

Permalink
Release/v1.4.3
Browse files Browse the repository at this point in the history
Release/v1.4.3
  • Loading branch information
dev-dong-su authored Feb 26, 2024
2 parents d75a51a + 62360c6 commit 8e9500a
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 171 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.yarn/cache

# testing
coverage
Expand Down
5 changes: 0 additions & 5 deletions .yarn/sdks/integrations.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .yarn/sdks/typescript/bin/tsc

This file was deleted.

20 changes: 0 additions & 20 deletions .yarn/sdks/typescript/bin/tsserver

This file was deleted.

16 changes: 5 additions & 11 deletions packages/app/src/components/OnBoarding.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useNavigation } from '@react-navigation/native';
import React, { useEffect, useRef, useState } from 'react';
import { Alert, Animated, Dimensions, Image, Text, TouchableOpacity, View } from 'react-native';
import { useEffect, useRef, useState } from 'react';
import { Animated, Dimensions, Image, Text, TouchableOpacity, View } from 'react-native';
import { ExpandingDot } from 'react-native-animated-pagination-dots';
import * as RNLocalize from 'react-native-localize';
import SplashScreen from 'react-native-splash-screen';
Expand Down Expand Up @@ -33,16 +33,10 @@ export default function OnBoarding() {
const [lang, setlang] = useState(null);
const preloading = async () => {
const isUserOnBoardSeen = await AsyncStorage.getItem('onBoarding');
const isUserLogin = await AsyncStorage.getItem('isUserLogin');
if (!isUserOnBoardSeen) return;
if (isUserLogin === 'true')
navigation.replace('WebViewContainer', {
url: `${SOURCE_URL}/grouping`,
});
else
navigation.replace('WebViewContainer', {
url: `${SOURCE_URL}/join?step=1`,
});
navigation.replace('WebViewContainer', {
url: `${SOURCE_URL}`,
});
};

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/web/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v17.5.0
v20.9.0
13 changes: 3 additions & 10 deletions packages/web/src/apis/auth/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useMutation } from '@tanstack/react-query';

import {
LoginResponse,
SignUpResponse,
Expand All @@ -9,21 +11,12 @@ import {
postSMSVerify,
postSignUp,
} from '.';

import useLogin from '@/hooks/token/useLogin';
import { useMutation } from '@tanstack/react-query';

export const useLoginMutation = () => {
const { login } = useLogin();

return useMutation({
mutationFn: postLogin,
onSuccess: async (response: LoginResponse) => {
await login({
accessToken: response.token.accessToken,
refreshToken: response.token.refreshToken,
userId: response.userId,
});
},
});
};

Expand Down
68 changes: 6 additions & 62 deletions packages/web/src/apis/community/mutations.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';

import {
deleteCommunityCommentLike,
postCommunityArticleLike,
Expand All @@ -9,44 +11,21 @@ import {
} from '@/apis/community/apis';
import { Keys } from '@/apis/community/keys';
import { CommunityArticle } from '@/apis/community/type';
import { CommunityChannelMessage } from '@/app/[lng]/(main)/community/components/ContentSection.client';
import useAppRouter from '@/hooks/useAppRouter';
import { useBroadcastChannel } from '@/hooks/useBroadcast';
import { getIsAndroid } from '@/utils/getIsAndroid';
import { getIsIOS } from '@/utils/getIsIOS';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { useGetCommunityArticleDetail } from './queries';

export const usePostCreateCommunityArticle = () => {
const queryClient = useQueryClient();
const { back } = useAppRouter();
const { postMessage } = useBroadcastChannel<CommunityChannelMessage>('community');

const isIOS = getIsIOS();
const isAndroid = getIsAndroid();

return useMutation({
mutationFn: postCreateCommunityArticle,
onSuccess: (data, variables) => {
const { categoryId } = variables;

if (isIOS || isAndroid) {
postMessage({ categoryId: Number(categoryId) });
} else {
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticles(0) }); // 전체 카테고리
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticles(categoryId) }); // 작성한 게시글 카테고리
}
onSuccess: () => {
back();
},
});
};

export const usePostCommunityArticleLike = (articleId: number, categoryId: number) => {
export const usePostCommunityArticleLike = (articleId: number) => {
const queryClient = useQueryClient();
const { postMessage } = useBroadcastChannel<CommunityChannelMessage>('community');

const isIOS = getIsIOS();
const isAndroid = getIsAndroid();

return useMutation({
mutationFn: () => postCommunityArticleLike(articleId),
Expand Down Expand Up @@ -76,56 +55,28 @@ export const usePostCommunityArticleLike = (articleId: number, categoryId: numbe
} else throw new Error('No previous Data');
},
onSettled: () => {
if (isIOS || isAndroid) {
postMessage({ categoryId });
} else {
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticles(0) });
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticles(categoryId) });
}
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticleDetail(articleId) });
},
});
};

export const usePostDeleteCommunityArticle = (articleId: number, categoryId: number) => {
const queryClient = useQueryClient();
export const usePostDeleteCommunityArticle = (articleId: number) => {
const { back } = useAppRouter();
const { postMessage } = useBroadcastChannel<CommunityChannelMessage>('community');

const isIOS = getIsIOS();
const isAndroid = getIsAndroid();

return useMutation({
mutationFn: () => postDeleteCommunityArticle(articleId),
onSuccess: () => {
if (isIOS || isAndroid) {
postMessage({ categoryId });
} else {
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticles(categoryId) });
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticles(0) });
}
back();
},
});
};

export const usePostCreateComment = (articleId: number, categoryId: number) => {
export const usePostCreateComment = (articleId: number) => {
const queryClient = useQueryClient();
const { postMessage } = useBroadcastChannel<CommunityChannelMessage>('community');

const isIOS = getIsIOS();
const isAndroid = getIsAndroid();

return useMutation({
mutationFn: postCreateCommunityComment,
onSuccess: () => {
if (isIOS || isAndroid) {
postMessage({ categoryId });
} else {
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticles(categoryId) });
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticles(0) });
}
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticleDetail(articleId) });
queryClient.invalidateQueries({ queryKey: Keys.getCommunityComments(articleId) });
},
});
Expand Down Expand Up @@ -168,17 +119,10 @@ export const useDeleteCommunityComment = (
categoryId: number
) => {
const queryClient = useQueryClient();
const { postMessage } = useBroadcastChannel<CommunityChannelMessage>('community');

const isIOS = getIsIOS();
const isAndroid = getIsAndroid();

return useMutation({
mutationFn: () => deleteCommunityCommentLike(articleId, commentId),
onSuccess: () => {
if (isIOS || isAndroid) {
postMessage({ categoryId });
}
queryClient.invalidateQueries({ queryKey: Keys.getCommunityComments(articleId) });
},
});
Expand Down
3 changes: 2 additions & 1 deletion packages/web/src/apis/community/queries.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useSuspenseInfiniteQuery, useSuspenseQuery } from '@tanstack/react-query';

import {
getCommunityArticleDetail,
getCommunityArticles,
getCommunityComments,
getCommunityReply,
} from '@/apis/community/apis';
import { Keys } from '@/apis/community/keys';
import { useSuspenseInfiniteQuery, useSuspenseQuery } from '@tanstack/react-query';

export const useGetCommunityArticles = (categoryId: number) => {
const { data, ...rest } = useSuspenseInfiniteQuery({
Expand Down
10 changes: 1 addition & 9 deletions packages/web/src/apis/config/privateApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,7 @@ privateApi.interceptors.request.use(
async (config: InternalAxiosRequestConfig) => {
try {
const { accessToken, refreshToken } = await getTokenFromCookie();
if (!accessToken || !refreshToken) return config;
const {
token: { accessToken: reIssuedAccessToken },
} = await postReissue(
{ accessToken, refreshToken },
{ headers: { 'X-AUTH-TOKEN': accessToken } }
);

config.headers['X-AUTH-TOKEN'] = reIssuedAccessToken;
config.headers['X-AUTH-TOKEN'] = accessToken;
return config;
} catch (error) {
return Promise.reject(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ function IconButtonAction() {
const { back } = useAppRouter();
const { data: articleData } = useGetCommunityArticleDetail(articleId);
const { open: openModal, exit: closeModal } = useModal();
const { mutate: mutateDelete } = usePostDeleteCommunityArticle(
articleId,
articleData.data.article.category.id
);
const { mutate: mutateDelete } = usePostDeleteCommunityArticle(articleId);

const handleBlockArticle = () => {
openModal(() => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function ArticleItem({ article }: ArticleItemProps) {
reliabilityLevel,
} = article.writer;

const { mutate: mutateLike } = usePostCommunityArticleLike(articleId, category.id);
const { mutate: mutateLike } = usePostCommunityArticleLike(articleId);

const handleLikeClick = () => {
mutateLike();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export default function CommentForm() {
const { t } = useTranslation('community');
const { articleId } = useNumberParams<['articleId']>();
const { commentType, commentId, setCommentType } = useCommentContext();
const categoryId = useGetCommunityArticleDetail(articleId).data.data.article.category.id;
const { mutate: mutateComment } = usePostCreateComment(articleId, categoryId);
const { mutate: mutateComment } = usePostCreateComment(articleId);
const { mutate: mutateReply } = useCreateCommunityReply(articleId);
const hookForm = useForm<CreateCommentRequest>({
mode: 'onChange',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Keys, getCommunityArticleDetail } from '@/apis/community';
import ArticleDetail from '@/app/[lng]/(main)/community/[articleId]/components/ArticleDetail';
import ArticleDetailHeader from '@/app/[lng]/(main)/community/[articleId]/components/ArticleDetailHeader';
import CommentForm from '@/app/[lng]/(main)/community/[articleId]/components/CommentForm';
import { LocalSuspenseErrorBoundary } from '@/components/ErrorBoundary';
import { HydrationProvider } from '@/components/Provider';
import { Spacing } from '@/components/Spacing';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import { useGetCommunityArticles } from '@/apis/community/queries';
import ArticleItem from '@/app/[lng]/(main)/community/components/ArticleItem.client';
import Empty from '@/app/[lng]/(main)/community/components/Empty';
import { ItemList } from '@/components/List';
import { Loading } from '@/components/Loading';
import { useBlockStore } from '@/store/useBlockStore';

export default function AllContent() {
const { ref, inView } = useInView();
const { blockCommunityArticleIds } = useBlockStore();
const { data: articleList, fetchNextPage } = useGetCommunityArticles(0);
const { data: articleList, fetchNextPage, isFetching, hasNextPage } = useGetCommunityArticles(0);

useEffect(() => {
if (inView) fetchNextPage();
if (inView && hasNextPage) fetchNextPage();
}, [inView, fetchNextPage]);

return (
<>
<ItemList
Expand All @@ -32,6 +32,7 @@ export default function AllContent() {
renderEmpty={() => <Empty />}
/>
<div ref={ref} />
{isFetching && <Loading className="h-10" />}
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
'use client';

import { useQueryClient } from '@tanstack/react-query';
import { Suspense } from 'react';

import AllContent from './AllContent.client';
import CreateArticleButton from './CreateArticleButton';
import KpopContent from './KpopContent';
import LanguageContent from './LanguageContent.client';
import QuestionContent from './QuestionContent.client';

import { Keys } from '@/apis/community';
import { useTranslation } from '@/app/i18n/client';
import { Tabs } from '@/components/Tabs';
import { useBroadcastChannel } from '@/hooks/useBroadcast';

export interface CommunityChannelMessage {
categoryId: number;
}

export default function ContentSection() {
const { t } = useTranslation('community');
const queryClient = useQueryClient();
const { postMessage } = useBroadcastChannel<CommunityChannelMessage>('community', (message) => {
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticles(0) });
queryClient.invalidateQueries({ queryKey: Keys.getCommunityArticles(message.categoryId) });
});

return (
<Tabs>
Expand Down
Loading

0 comments on commit 8e9500a

Please sign in to comment.