Skip to content

Commit 13847fd

Browse files
authored
Merge pull request #142 from wafflestudio/141-feature-final
✨ feat: 스토리 조회수 구현
2 parents 859d69b + ad2c8fb commit 13847fd

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/entities/story/model/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface Story {
44
imageUrl: string
55
createdAt: string
66
expiresAt?: string
7+
viewCount?: number
78
}
89

910
export interface StoryFeedItem {

src/features/story-viewer/ui/StoryViewer.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,25 @@ export function StoryViewer({ feed, userId }: StoryViewerProps) {
226226
</p>
227227
</div>
228228
) : (
229-
<img
230-
key={currentStory.imageUrl}
231-
src={currentStory.imageUrl}
232-
className="h-full w-full object-cover select-none"
233-
alt="story"
234-
onError={() => setImageError(true)}
235-
referrerPolicy="no-referrer"
236-
/>
229+
<>
230+
<img
231+
key={currentStory.imageUrl}
232+
src={currentStory.imageUrl}
233+
className="h-full w-full object-cover select-none"
234+
alt="story"
235+
onError={() => setImageError(true)}
236+
referrerPolicy="no-referrer"
237+
/>
238+
239+
{/* 내 스토리일 때 좌측 하단에 조회수 표시 */}
240+
{isMine && currentStory.viewCount !== undefined && (
241+
<div className="absolute bottom-4 left-4 z-50 flex flex-col items-start gap-1">
242+
<span className="text-[13px] font-semibold text-white drop-shadow-md">
243+
{currentStory.viewCount}명이 읽음
244+
</span>
245+
</div>
246+
)}
247+
</>
237248
)}
238249
</div>
239250
</div>

src/mocks/handlers/story.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const StoryFeedItemSchema = z.object({
1616
userId: z.string(),
1717
imageUrl: z.string(),
1818
createdAt: z.string(),
19+
viewCount: z.number().optional(),
1920
})
2021
),
2122
})
@@ -69,6 +70,7 @@ export const storyHandlers = [
6970
userId: String(s.userId),
7071
imageUrl: s.imageUrl,
7172
createdAt: s.createdAt,
73+
viewCount: s.viewCount,
7274
}))
7375

7476
if (userStories.length === 0) return null

0 commit comments

Comments
 (0)