Skip to content

Commit

Permalink
refactor: main basetime 단위 변경
Browse files Browse the repository at this point in the history
기존 밀리세컨드로 보내던 basetime을 백엔드팀 요청에 따라 세컨드로 변경함

close #61
  • Loading branch information
ppark2ya committed Feb 17, 2022
1 parent 9a41e65 commit 4a856dc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Card from '~/components/Main/Card';
import { SkeletonCard } from '~/components/Skeleton';
import { DEFAULT_SEARCH_RANGE } from '~/shared/constants/pagination';
import { NextSeo } from 'next-seo';
import { MILLISEC_TO_SECOND } from '~/shared/constants/unit';

const StyledMain = styled('div', {
gridArea: 'main',
Expand Down Expand Up @@ -43,7 +44,7 @@ const StyledCardList = styled(Box, {
const initialState: ContentsSearchParams = {
start: 0,
count: DEFAULT_SEARCH_RANGE,
baseTime: Date.now(),
baseTime: Math.floor(Date.now() / MILLISEC_TO_SECOND),
keyword: '',
};

Expand All @@ -56,7 +57,7 @@ const Main: NextPage = function () {
const { onChange, onEnter, onSearch } = useSearch((keyword: string) => {
setSearchParams((prev) => ({
...prev,
baseTime: Date.now(),
baseTime: Math.floor(Date.now() / MILLISEC_TO_SECOND),
keyword,
}));
});
Expand Down
5 changes: 3 additions & 2 deletions pages/writers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { StyledCard } from '~/components/Main/Card';
import { SkeletonCard } from '~/components/Skeleton';
import { DEFAULT_SEARCH_RANGE } from '~/shared/constants/pagination';
import { NextSeo } from 'next-seo';
import { MILLISEC_TO_SECOND } from '~/shared/constants/unit';

const StyledMain = styled('div', {
gridArea: 'main',
Expand Down Expand Up @@ -44,7 +45,7 @@ const StyledCardList = styled(Box, {
const initialState: ContentsSearchParams = {
start: 0,
count: DEFAULT_SEARCH_RANGE,
baseTime: Date.now(),
baseTime: Math.floor(Date.now() / MILLISEC_TO_SECOND),
keyword: '',
};

Expand All @@ -57,7 +58,7 @@ const Main: NextPage = function () {
const { onChange, onEnter, onSearch } = useSearch((keyword: string) => {
setSearchParams((prev) => ({
...prev,
baseTime: Date.now(),
baseTime: Math.floor(Date.now() / MILLISEC_TO_SECOND),
keyword,
}));
});
Expand Down
1 change: 1 addition & 0 deletions shared/constants/unit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const MILLISEC_TO_SECOND = 1000;

0 comments on commit 4a856dc

Please sign in to comment.