Compare commits

..
Author SHA1 Message Date
minaChoi 4875ea4333 Merge remote-tracking branch 'origin/main' into feat/apps-in-toss
# Conflicts:
#	frontend/src/b/BLayout.tsx
#	frontend/src/b/Shorts.tsx
#	frontend/src/b/talk.tsx
2026-10-27 19:08:51 +09:00
minaChoi 77cfb04808 feat: 토스판 첫 실행 인트로 다시 넣음 (51e0c06 되돌림) — 토스 로그인을 다시 켜서 검수 의견대로 로그인 전에 서비스 소개 2026-10-27 08:30:54 +09:00
minaChoi 9dc7a52383 feat: 토스판 토스 로그인 다시 켬 (0144a64 되돌림) — 로그인 버튼·글쓰기 칸·글 더보기, 두 번째 내 각 저장 때 로그인 창 2026-10-27 08:30:41 +09:00
minaChoi 130f14e96a fix: 토스판 쇼츠를 열거나 넘길 때 검은 플레이어가 깜빡임 — 재생 상태가 안 오므로 플레이어 문서가 뜨고 1초 뒤까지 표지로 가렸다가 서서히 띄움 2026-10-26 16:41:15 +09:00
minaChoi b240ecb180 fix: 토스판 쇼츠는 유튜브 기본 플레이어로 자동재생 — 토스 웹뷰엔 플레이어 재생 상태가 안 와서 숨기기·명령·재생 아이콘을 쓰지 않고, 소리 켠 채 재생(막히면 유튜브 재생 버튼), 넘기기는 이전·다음 버튼. 웹은 그대로 2026-10-26 16:33:50 +09:00
minaChoi 21bfa2a3ff fix: 토스판 쇼츠는 유튜브 기본 플레이어로 — 토스 웹뷰엔 재생 상태가 안 와서 자동재생·숨기기 대신 재생 버튼을 처음부터 보이고, 카드는 표지와 재생 아이콘, 쇼츠 페이지에 이전·다음 버튼 2026-10-26 16:24:45 +09:00
minaChoi 61023d090e fix: 쇼츠 재생 아이콘을 플레이어가 보낸 재생 상태로만 판단 — 늦은 자동재생과 누르기가 겹쳐도 어긋나지 않게, 카드 아이콘은 플레이어 위에, 넘기기 판은 재생 명령이 막힌 때만 치움 2026-10-26 16:18:09 +09:00
minaChoi 2fd6fcbd06 fix: 쇼츠 재생 멈춤 표시를 effect 안 setState 없이 2026-10-26 16:12:02 +09:00
minaChoi acb6c4d717 fix: 쇼츠가 저절로 재생되지 않으면(토스 웹뷰) 2초 뒤 플레이어를 보이고 재생 아이콘을 띄워 직접 눌러 재생 2026-10-26 16:11:49 +09:00
minaChoi 81b17f057f fix: 토스판 쇼츠 재생 — 웹뷰 기본값(자동재생·화면 안 재생 막음)을 풀어 줌 2026-10-26 16:03:54 +09:00
minaChoi 51e0c06f2d fix: 토스판 첫 실행 인트로 뺌 — 토스 로그인을 뺐으니 로그인 전 소개 화면이 필요 없음 2026-10-26 15:52:06 +09:00
minaChoi 0a84f34729 Merge remote-tracking branch 'origin/main' into feat/apps-in-toss 2026-10-26 15:46:15 +09:00
minaChoi 2627dd2685 Merge remote-tracking branch 'origin/main' into feat/apps-in-toss 2026-10-26 15:33:39 +09:00
6 changed files with 133 additions and 105 deletions

No files matched your search

+1 -4
View File
@@ -63,10 +63,6 @@
| [ ] | **[결정 필요]** 쇼츠 문구 검토: '소리 켜기'/'소리 끄기' (줄 제목은 없앰) | 화면 문구 규칙 | `frontend/src/b/Shorts.tsx` |
| [ ] | 쇼츠를 올린 직후 목록 갱신(`ShortsService.refresh`) 부르기 — 지금은 워커가 07·12·18시 10분에만 받아 18시 넘어 올리면 다음 날 아침에 뜸. 자동 업로드면 끝난 뒤 호출, 손으로 올리면 관리자 갱신 API | 올리는 방식 확인 필요 | `backend/services/shorts_service.py`, `backend/worker_main.py` |
| [ ] | 쇼츠 API 실패·빈 목록일 때 공유 링크로 들어오면 남색 빈 화면만 보임 — 그 영상 ID 하나라도 띄우거나 × 버튼·안내 문구 보이기 | 10/27 QA 실패 (`items` 가 비면 빈 div 만 그림) | `frontend/src/b/Shorts.tsx` |
| [ ] | **[결정 필요]** 쇼츠 폰에서 유튜브 멈춤(\|\|) 버튼이 계속 남음 — 유튜브 플레이어 자체 버튼이라 코드로 못 지움. 우리 쇼츠 원본 mp4를 저장소에 올려 <video>로 틀지, 폰 연결해 유튜브로 더 시도할지 | 10/27 실기기 보고, 크롬·WebKit 흉내에선 재현 안 됨 | `frontend/src/b/Shorts.tsx` |
| [ ] | 토스 ait 는 `feat/apps-in-toss` 브랜치(~/orca/workspaces/o2o-weather/main-3)에서 만들기 — main 에는 토스 로그인·웹뷰 자동재생·쇼츠 토스 처리가 없음. 최신 ait 20:03 콘솔 업로드 필요 | 10/27 main 에서 만든 ait 로 쇼츠가 멈춰 보임 | `~/orca/workspaces/o2o-weather/main-3/frontend/nalssigak.ait` |
| [ ] | 운영 행사 주소(event.address) 채우기 — 팝가가 연속 요청을 막아(429) 로컬도 206개 중 80개만. 간격 두고 다시 | 10/27 주소 수집 추가 | `backend/scheduler/jobs.py` `refresh_popups` |
| [ ] | `test_watch_summary_flags_thunder_within_2_hours` 가 전체로 돌릴 때만 실패(따로 돌리면 통과) — 순서 의존 원인 찾기 | 10/27 전체 테스트 | `backend/tests/test_watch.py` |
| [ ] | 쇼츠 자동재생 아이폰 사파리 실기기 확인 — 소리 꺼도 자동재생을 막는다는 보고 있음 | 헤드리스 크롬에서만 확인 | `frontend/src/b/Shorts.tsx` |
| [x] | 단풍 명소 `남이섬`이 두 번 들어감(절정 10-25·10-27) — 10-27(화목원) 쪽 지움, 67곳 | 10/27 전체 점검 | `frontend/seo/foliage_2026.json` |
| [x] | 날짜 따라 깨지던 테스트 2개 — 노을 칸은 그날 해 지는 시각으로, 방위각은 한 해 범위(240~300°)로 확인 | 10/27 전체 점검 | `backend/tests/test_weather_today.py`, `backend/tests/test_sky_api.py` |
@@ -245,6 +241,7 @@
| [ ] | 토스 로그인 문구 검토 — '토스로 로그인', '토스로 로그인했어요', '토스 로그인을 마치지 못했어요. 한 번 더 눌러 주세요.', 기본 닉네임 '토스1234'(userKey 끝 4자리), 로그인 창 '날씨각 로그인'·'로그인하면 동네 이야기를 쓰고 내 각을 저장할 수 있어요', 인트로 '오늘 날씨에 맞는 일을 점수로 알려 줘요'·'세차·빨래·러닝 각 점수'·'오늘 노을이 예쁜 시간'·'이번 주말 가까운 행사'·'시작하기'(10/24) | 토스 로그인 구현(10/14) | `frontend/src/b/Sheets.tsx`, `backend/services/auth_service.py` |
| [ ] | 토스판 첫 실행에 인트로와 위치 권한 창이 같이 뜸 — 위치 권한은 앱이 뜨자마자 물어서 인트로 위에 겹칠 수 있음. '시작하기' 뒤로 미룰지 토스 앱에서 확인 | 인트로 추가 (10/24) | `frontend/src/b/region.tsx`, `frontend/src/b/tossIntro.tsx` |
| [ ] | 메뉴의 '로그인하면 좋아요·댓글을 쓸 수 있어요' — 좋아요·댓글은 로그인 없이 됨(10/21 결정)이라 문구가 틀림 | 인트로 추가 중 발견 (10/24) | `frontend/src/b/Sheets.tsx:1117` |
| [ ] | 토스 웹뷰에서 유튜브 플레이어가 보내는 재생 상태(postMessage)가 페이지에 오지 않음 — 원인 미확인(origin 불일치? 토스 브리지?). 그래서 토스판 쇼츠는 숨기기·명령 없이 유튜브 기본 플레이어 사용. 원인 찾으면 웹과 같은 UI로 합칠 수 있음 | 토스판 쇼츠 재생 안 됨 (10/26) | `frontend/src/b/Shorts.tsx` |
| [ ] | 댓글 신고·차단 — 앱인토스 필수 아님(신고·차단 필수는 채팅·만남·중고거래만, 서비스 오픈 정책·서비스별 주의사항). 만들지 않기로 함(10/14). 검수에서 요청이 오면 만든다 | 토스 로그인 구현(10/14) | |
| [x] | 각 늘리기 53→68 — 리서치로 고른 8개(한강·놀이공원·데이트·곱슬머리·보일러·선크림·모기·테니스) + 감성 7개(효도·감사·선물·파티·게임·셀카·센치), 아이콘 15개(Codex) | 사용자 요청 (10/20, 리서치 https://claude.ai/artifact/3ZQbtGKRLVZViRRC5voBzY) | `backend/seed/index_definition.json`, `frontend/public/icons/`, `frontend/src/b/lib.ts` |
| [ ] | **[결정 필요]** 한강각·놀이공원각이 강·놀이공원 없는 동네에도 나옴 — 각을 지역별로 가려 보여 주는 기능이 없음(한강밤바람각도 같음). 서울·한강 인접 구만 보일지 | 새 각 추가 중 발견 (10/20) | `backend/seed/index_definition.json`, `backend/services/index_service.py` |
+2
View File
@@ -6,5 +6,7 @@ export default defineConfig({
brand: { primaryColor: '#ff7a45' },
permissions: [{ name: 'geolocation', access: 'access' }],
navigationBar: { withBackButton: true, withHomeButton: true },
// 기본값은 자동재생·화면 안 재생을 막아 쇼츠(유튜브)가 재생되지 않는다
webView: { allowsInlineMediaPlayback: true, mediaPlaybackRequiresUserAction: false },
webBundleDir: 'dist-toss',
})
+2 -3
View File
@@ -2,7 +2,6 @@ import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react
import { NavLink, Outlet, useLocation, useNavigationType } from 'react-router'
import { useIsFetching, useQuery, useQueryClient } from '@tanstack/react-query'
import { authConfigOptions, getSeasonWeekOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { IS_TOSS } from '../lib/platform'
import { cx } from '../lib/utils'
import { kindOfHour, kst, seasonOf, type TimeKind } from '@nalssigak/shared/lib'
import './b.css'
@@ -50,7 +49,7 @@ function TopBar() {
const { me, mePending } = useAuth()
const queryClient = useQueryClient()
const tab = TABS.find((t) => t.to !== '/' && pathname.startsWith(t.to))
const loggedOut = !IS_TOSS && !mePending && !me
const loggedOut = !mePending && !me
// 로그인 창을 처음 열 때 버벅이지 않게 구글 로그인 준비물을 미리 받아 둔다
useEffect(() => {
@@ -72,7 +71,7 @@ function TopBar() {
<PinIcon className="size-3.5 shrink-0" />
{locateStatus === 'locating' ? <Skel className="w-[72px]" /> : <span className="truncate whitespace-nowrap"><span className="max-[399px]:hidden">{region.name}</span><span className="min-[400px]:hidden">{region.name.split(' ').at(-1)}</span></span>}
</button>
{IS_TOSS ? null : mePending ? (
{mePending ? (
<Skel shape className="size-9 shrink-0 rounded-full" />
) : me ? (
<button type="button" onClick={() => open({ type: 'me' })} aria-label={`내 정보, ${me.nickname}`} className="shrink-0 cursor-pointer rounded-full shadow-[0_6px_12px_rgb(40_48_74/0.12)]">
+49 -9
View File
@@ -20,6 +20,7 @@ import {
listRegionsOptions,
meQueryKey,
reportCommentMutation,
tossMutation,
unblockMutation,
unlikeCommentMutation,
updateMeMutation,
@@ -27,7 +28,7 @@ import {
} from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { AuthProvider, ReportReason, type CommentData, type Factor, type ResAuth, type ResCommentList, type ResIndexDetail } from '@nalssigak/shared/api/client/types.gen'
import { track } from '../lib/analytics'
import { IS_TOSS, tossShare } from '../lib/platform'
import { IS_TOSS, tossLogin, tossShare } from '../lib/platform'
import { cx } from '../lib/utils'
import { useAuth } from './authContext'
import { ago, articleMeta, AVATAR_COLORS, cardBg, CHARACTERS, dateRange, loadOf, MOODS, shortDay } from '@nalssigak/shared/lib'
@@ -993,7 +994,7 @@ function LoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLoggedIn: ()
const fail = () => setError('서버에 닿지 못했어요. 잠시 뒤에 다시 해 주세요.')
if (me) return <MeSheet onDone={onDone} />
if (IS_TOSS) return <TossNoLoginSheet onDone={onDone} />
if (IS_TOSS) return <TossLoginSheet onDone={onDone} onLoggedIn={onLoggedIn} />
return (
<Body>
@@ -1017,13 +1018,52 @@ function LoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLoggedIn: ()
)
}
/** 토스판은 로그인이 없다. 로그인이 필요한 곳(두 번째 내 각)에서 안내만 한다 */
function TossNoLoginSheet({ onDone }: { onDone: () => void }) {
/** 앱인토스는 토스 로그인만 쓸 수 있다 */
function TossLoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLoggedIn: () => void }) {
const [error, setError] = useState('')
const [opening, setOpening] = useState(false)
const toss = useMutation(tossMutation())
const pending = opening || toss.isPending
const start = async () => {
setError('')
setOpening(true)
let code: Awaited<ReturnType<typeof tossLogin>>
try {
code = await tossLogin()
} catch (e) {
console.error('[login] toss', e)
setError('토스 로그인을 마치지 못했어요. 한 번 더 눌러 주세요.')
return
} finally {
setOpening(false)
}
toss.mutate(
{ body: { authorization_code: code.authorizationCode, referrer: code.referrer } },
{
onSuccess: (res) => {
if (!res.result?.success || !res.access_token) return setError('토스 로그인을 마치지 못했어요. 한 번 더 눌러 주세요.')
setTokens(res.access_token, res.refresh_token ?? null)
track('login', { method: 'toss' })
onLoggedIn()
},
onError: () => setError('서버에 닿지 못했어요. 잠시 뒤에 다시 해 주세요.'),
},
)
}
return (
<Body className="flex flex-col gap-2.5">
<p className="m-0 text-center text-sm font-semibold text-(--ink2)">토스에서는 내 각을 하나만 만들 수 있어요. 지금 각을 지우고 새로 만들어 주세요.</p>
<button type="button" onClick={onDone} className="cursor-pointer rounded-[14px] bg-(--orange) p-[13px] font-jua text-[17px] text-white shadow-[inset_0_-5px_0_var(--orange-deep)]">
알겠어요
<h3 className="m-0 text-center font-jua text-xl font-normal">날씨각 로그인</h3>
<p className="m-0 text-center text-sm font-semibold text-(--ink2)">로그인하면 동네 이야기를 쓰고 내 각을 저장할 수 있어요</p>
<p className="min-h-5 text-center text-[13px] font-bold text-(--heart)" aria-live="polite">
{error}
</p>
<button type="button" onClick={start} disabled={pending} className="cursor-pointer rounded-[14px] bg-(--orange) p-[13px] font-jua text-[17px] text-white shadow-[inset_0_-5px_0_var(--orange-deep)] disabled:opacity-60">
<Swap labels={['토스로 로그인', '로그인 중…']} at={pending ? 1 : 0} />
</button>
<button type="button" onClick={onDone} className="cursor-pointer rounded-[14px] p-[13px] text-[15px] font-extrabold text-(--ink2)">
나중에 할게요
</button>
</Body>
)
@@ -1320,12 +1360,12 @@ function RegionSheet({ onDone }: { onDone: () => void }) {
</li>
))}
</ul>
{!IS_TOSS && <p className="mt-4 flex items-center justify-center gap-2 text-[13px] font-bold text-(--ink2)">
<p className="mt-4 flex items-center justify-center gap-2 text-[13px] font-bold text-(--ink2)">
{me ? `${me.nickname}(으)로 로그인했어요` : '로그인하면 좋아요·댓글을 쓸 수 있어요'}
<button type="button" onClick={me ? logout : () => open({ type: 'login' })} className="cursor-pointer font-extrabold text-(--rain)">
{me ? '로그아웃' : '로그인'}
</button>
</p>}
</p>
</Body>
)
}
+69 -75
View File
@@ -37,20 +37,21 @@ function useTabBarHeight() {
const YT_ORIGIN = 'https://www.youtube-nocookie.com'
// 토스 웹뷰에는 플레이어가 보내는 재생 상태가 오지 않는다. 그래서 토스는 첫 장면이 나왔는지를 시간으로 보고 표지를 걷는다 (나머지는 웹과 같다)
// 토스 웹뷰에는 플레이어가 보내는 재생 상태가 오지 않아, 쇼츠 페이지는 플레이어를 숨기거나 명령하지 않고 유튜브 기본 조작(재생 버튼)과 소리를 켠 채 그대로 보인다.
// 영상 위 터치는 유튜브가 가져가므로 넘기기는 버튼으로
const PLAIN = IS_TOSS
// 토스는 재생 상태가 안 오므로, 플레이어 문서가 뜨고 이만큼 지나면 첫 장면이 나왔다고 보고 표지를 걷는다 (그 전엔 플레이어의 검은 화면 대신 표지)
const PLAIN_SHOW_MS = 1000
function embed(id: string) {
function embed(id: string, plain = false) {
const q = new URLSearchParams({
autoplay: '1', mute: '1', playsinline: '1', loop: '1', playlist: id, controls: '0', rel: '0', modestbranding: '1',
autoplay: '1', mute: plain ? '0' : '1', playsinline: '1', loop: '1', playlist: id, controls: plain ? '1' : '0', rel: '0', modestbranding: '1',
enablejsapi: '1', origin: window.location.origin,
})
return `${YT_ORIGIN}/embed/${id}?${q}`
}
type Func = 'playVideo' | 'seekTo' | 'mute' | 'unMute'
type Func = 'playVideo' | 'pauseVideo' | 'seekTo' | 'mute' | 'unMute'
/** 이미 띄운 플레이어에 명령 (IFrame API 메시지) */
function command(frame: HTMLIFrameElement | null | undefined, func: Func, args: unknown[] = []) {
@@ -106,35 +107,16 @@ export function ShortsRail() {
}
function ShortCard({ s, playing }: { s: ShortItem; playing: boolean }) {
// 재생이 시작된 뒤에만 플레이어를 보인다: 자동재생이 막히면(아이폰 절전 등) 유튜브 재생 버튼 대신 표지 그대로
const [started, setStarted] = useState(false)
const frame = useRef<HTMLIFrameElement>(null)
useEffect(() => {
if (!playing) return
const onMessage = (e: MessageEvent) => {
if (e.origin !== YT_ORIGIN || typeof e.data !== 'string' || e.source !== frame.current?.contentWindow) return
try {
if ((JSON.parse(e.data) as { info?: { playerState?: number } }).info?.playerState === PLAYING) setStarted(true)
} catch {
return
}
}
window.addEventListener('message', onMessage)
return () => window.removeEventListener('message', onMessage)
}, [playing])
return (
<Link to={`/shorts/${s.id}`} aria-label={`${s.title} 보기`} className="relative block aspect-[9/16] w-[120px] cursor-pointer overflow-hidden rounded-xl bg-[#1d2233] p-0 text-left text-white">
<img src={`https://i.ytimg.com/vi/${s.id}/hqdefault.jpg`} alt="" loading="lazy" className="absolute inset-0 size-full object-cover" />
{playing && (
<iframe
ref={frame}
src={embed(s.id)}
title={s.title}
allow="autoplay; encrypted-media; picture-in-picture"
tabIndex={-1}
// 재생 상태를 받으려면 플레이어에 먼저 '듣고 있다'고 알린다
onLoad={(e) => e.currentTarget.contentWindow?.postMessage(JSON.stringify({ event: 'listening', id: s.id }), YT_ORIGIN)}
className={cx('pointer-events-none absolute top-1/2 left-1/2 border-0 transition-opacity duration-200', !started && 'opacity-0')}
className="pointer-events-none absolute top-1/2 left-1/2 border-0"
style={{ width: PLAYER_W, height: (PLAYER_W * 16) / 9, transform: `translate(-50%, -50%) scale(${SCALE})` }}
/>
)}
@@ -171,37 +153,26 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
const tabH = useTabBarHeight()
// 첫 장면을 받은 플레이어. 그 전엔 플레이어의 검은 화면 대신 표지를 보인다
const [ready, setReady] = useState<ReadonlySet<number>>(new Set())
// 토스: 표지를 걷은 플레이어들. 다음 영상도 미리 띄워 두므로 여럿
const [plainShown, setPlainShown] = useState<ReadonlySet<number>>(new Set())
const plainTimers = useRef(new Set<number>())
useEffect(() => {
const timers = plainTimers.current
return () => timers.forEach((t) => window.clearTimeout(t))
}, [])
// 토스: 표지를 걷은 플레이어 번호 (하나만 띄우므로 하나)
const [plainShownAt, setPlainShownAt] = useState(-1)
const plainTimer = useRef(0)
useEffect(() => () => window.clearTimeout(plainTimer.current), [])
const frames = useRef(new Map<number, HTMLIFrameElement>())
const atRef = useRef(start)
const soundRef = useRef(false)
// 누르기로 멈춘 상태. 다른 영상으로 넘어가면 다시 재생 중으로
const paused = useRef(false)
// 처음 한 번: 시작 영상으로 맞추고, 뒤 페이지 스크롤을 잠근다
const startRef = useRef(start)
// 시작 영상으로 옮기기 전엔 보이는 칸이 바뀐 것으로 치지 않는다 (사파리는 처음 그릴 때 맨 위 칸이 먼저 보여 첫 영상으로 바뀌던 것)
const placed = useRef(false)
useLayoutEffect(() => {
// scrollIntoView 는 바깥 칸까지 굴려 버튼 줄이 헤더 밑으로 숨으므로 목록만 옮긴다. 사파리는 첫 그림 전에 옮긴 값을 되돌려 한 번 더
useEffect(() => {
// scrollIntoView 는 바깥 칸까지 굴려 버튼 줄이 헤더 밑으로 숨으므로 목록만 옮긴다
const box = list.current
const place = () => {
if (box) box.scrollTop = box.clientHeight * startRef.current
}
place()
const raf = requestAnimationFrame(() => {
place()
placed.current = true
})
if (box) box.scrollTop = box.clientHeight * startRef.current
const root = document.documentElement
const before = root.style.overflow
root.style.overflow = 'hidden'
return () => {
cancelAnimationFrame(raf)
root.style.overflow = before
}
}, [])
@@ -217,7 +188,6 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
if (!box) return
const io = new IntersectionObserver(
(entries) => {
if (!placed.current) return
for (const e of entries) if (e.isIntersecting) setAt(Number((e.target as HTMLElement).dataset.i))
},
{ root: box, threshold: 0.6 },
@@ -226,7 +196,7 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
return () => io.disconnect()
}, [])
// 플레이어가 재생을 시작하면(첫 장면을 받음) 보이게 한다. 앞뒤 영상은 멈추지 않는다: 멈췄다 다시 틀면 유튜브가 재생·멈춤 버튼을 영상 위에 띄운다
// 미리 띄운 영상이 재생되기 시작하면(첫 장면을 받음) 보이는 영상이 아닐 때 멈추고 처음으로
useEffect(() => {
const onMessage = (e: MessageEvent) => {
if (e.origin !== YT_ORIGIN || typeof e.data !== 'string') return
@@ -240,6 +210,9 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
for (const [i, f] of frames.current) {
if (f.contentWindow !== e.source) continue
setReady((r) => (r.has(i) ? r : new Set(r).add(i)))
if (i === atRef.current) continue
command(f, 'pauseVideo')
command(f, 'seekTo', [0, true])
}
}
window.addEventListener('message', onMessage)
@@ -250,21 +223,28 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
useEffect(() => {
if (atRef.current !== at) moved(items[at])
atRef.current = at
// 앞뒤 영상은 소리 없이 계속 돌고 있으니, 넘어온 영상만 처음부터 다시 틀고 소리를 맞춘다 (멈춤 명령은 쓰지 않는다)
paused.current = false
if (PLAIN) return
for (const [i, f] of frames.current) {
if (i === at) {
command(f, 'seekTo', [0, true])
command(f, soundRef.current ? 'unMute' : 'mute')
command(f, 'playVideo')
} else command(f, 'mute')
} else {
command(f, 'pauseVideo')
command(f, 'mute')
}
}
}, [at, items])
// 마우스로도 끌어 넘긴다: 영상 위는 유튜브 iframe 이 마우스를 가져가서, 그 위에 투명한 판을 깔고 끈 만큼 목록을 옮긴다.
// 손가락은 브라우저 스크롤에 맡기고, 끌지 않고 누르기만 하면 릴스처럼 소리 켜기·끄기 (멈추면 유튜브 버튼이 떠서)
// 손가락은 브라우저 스크롤에 맡기고, 끌지 않고 누르기만 하면 재생·일시정지
const drag = useRef<{ y: number; top: number; moved: boolean } | null>(null)
const lastPointer = useRef('')
const [dragging, setDragging] = useState(false)
const togglePause = () => {
paused.current = !paused.current
command(frames.current.get(atRef.current), paused.current ? 'pauseVideo' : 'playVideo')
}
const onPointerDown = (e: ReactPointerEvent<HTMLDivElement>) => {
lastPointer.current = e.pointerType
const box = list.current
@@ -287,7 +267,7 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
drag.current = null
setDragging(false)
if (!d || !box) return
if (!d.moved) return toggleSound()
if (!d.moved) return togglePause()
// 30px 만 끌어도 다음·이전 영상으로, 그보다 덜 끌면 제자리로
const h = box.clientHeight
const dy = e.clientY - d.y
@@ -296,6 +276,11 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
box.scrollTo({ top: target * h, behavior: 'smooth' })
}
const go = (step: number) => {
const box = list.current
if (box) box.scrollTo({ top: (at + step) * box.clientHeight, behavior: 'smooth' })
}
const toggleSound = () => {
const on = !sound
soundRef.current = on
@@ -325,33 +310,40 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
<button type="button" onClick={onClose} aria-label="닫기" className={cx('relative grid size-9 cursor-pointer place-items-center rounded-full bg-white/15 text-white', TAP44)}>
<CloseIcon className="size-[18px]" />
</button>
<button type="button" onClick={toggleSound} aria-pressed={sound} className="h-9 cursor-pointer rounded-full bg-white/15 px-3.5 text-[13px] font-bold text-white">
{sound ? '소리 끄기' : '소리 켜기'}
</button>
{PLAIN ? (
<div className="flex gap-2">
<button type="button" onClick={() => go(-1)} disabled={at === 0} className="h-9 cursor-pointer rounded-full bg-white/15 px-3.5 text-[13px] font-bold text-white disabled:opacity-40">
▲ 이전
</button>
<button type="button" onClick={() => go(1)} disabled={at === items.length - 1} className="h-9 cursor-pointer rounded-full bg-white/15 px-3.5 text-[13px] font-bold text-white disabled:opacity-40">
▼ 다음
</button>
</div>
) : (
<button type="button" onClick={toggleSound} aria-pressed={sound} className="h-9 cursor-pointer rounded-full bg-white/15 px-3.5 text-[13px] font-bold text-white">
{sound ? '소리 끄기' : '소리 켜기'}
</button>
)}
</div>
<div ref={list} className={cx('relative min-h-0 flex-1 overflow-y-auto [scrollbar-width:none]', !dragging && 'snap-y snap-mandatory')}>
{items.map((s, i) => (
<div key={s.id} data-i={i} className="relative grid h-full snap-start place-items-center">
<div className="relative" style={FIT}>
<img src={`https://i.ytimg.com/vi/${s.id}/hqdefault.jpg`} alt="" className="absolute inset-0 size-full object-cover" />
{/* 릴스처럼 앞뒤 영상을 소리 없이 미리 받아 둔다 */}
{Math.abs(i - at) <= 1 && (
{(PLAIN ? i === at : Math.abs(i - at) <= 1) && (
<iframe
ref={(f) => {
if (f) frames.current.set(i, f)
else frames.current.delete(i)
}}
src={embed(s.id)}
src={embed(s.id, PLAIN)}
title={s.title}
allow="autoplay; encrypted-media; picture-in-picture"
// 재생 상태를 받으려면 플레이어에 먼저 '듣고 있다'고 알린다
onLoad={(e) => {
if (PLAIN) {
const t = window.setTimeout(() => {
plainTimers.current.delete(t)
setPlainShown((r) => (r.has(i) ? r : new Set(r).add(i)))
}, PLAIN_SHOW_MS)
plainTimers.current.add(t)
window.clearTimeout(plainTimer.current)
plainTimer.current = window.setTimeout(() => setPlainShownAt(i), PLAIN_SHOW_MS)
}
e.currentTarget.contentWindow?.postMessage(JSON.stringify({ event: 'listening', id: s.id }), YT_ORIGIN)
// 앞뒤 밖으로 밀려나 내려갔다 다시 뜬 플레이어는 첫 장면을 새로 받을 때까지 다시 숨긴다
@@ -362,21 +354,23 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
return next
})
}}
className={cx('absolute inset-0 size-full border-0 transition-opacity duration-200', (PLAIN ? !plainShown.has(i) : !ready.has(i)) && 'opacity-0')}
className={cx('absolute inset-0 size-full border-0 transition-opacity duration-200', (PLAIN ? plainShownAt !== i : !ready.has(i)) && 'opacity-0')}
/>
)}
{!PLAIN && (
<div
aria-hidden="true"
onPointerDown={onPointerDown}
onPointerMove={onPointerMove}
onPointerUp={onPointerUp}
onPointerCancel={() => {
drag.current = null
setDragging(false)
}}
onClick={() => lastPointer.current !== 'mouse' && togglePause()}
className={cx('absolute inset-0 touch-pan-y select-none', dragging ? 'cursor-grabbing' : 'cursor-grab')}
/>
)}
<div
aria-hidden="true"
onPointerDown={onPointerDown}
onPointerMove={onPointerMove}
onPointerUp={onPointerUp}
onPointerCancel={() => {
drag.current = null
setDragging(false)
}}
onClick={() => lastPointer.current !== 'mouse' && toggleSound()}
className={cx('absolute inset-0 touch-pan-y select-none', dragging ? 'cursor-grabbing' : 'cursor-grab')}
/>
</div>
</div>
))}
+10 -14
View File
@@ -12,7 +12,6 @@ import {
import { uploadTalkImage } from '@nalssigak/shared/api/client/sdk.gen'
import { TalkReport, TalkTopic, type TalkData } from '@nalssigak/shared/api/client/types.gen'
import { API_BASE_URL } from '../api/setup'
import { IS_TOSS } from '../lib/platform'
import { cx } from '../lib/utils'
import { useAuth } from './authContext'
import { kst } from '@nalssigak/shared/lib'
@@ -309,17 +308,15 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
</div>
{/* 글 메뉴(⋯)는 하트 옆 오른쪽 위에: 아래 줄 끝에 두면 말줄임표처럼 읽힌다 */}
<span className="flex items-start gap-4 self-start">
{!IS_TOSS && (
<button
type="button"
onClick={() => setMenu(menu === 'closed' ? 'open' : 'closed')}
aria-expanded={menu !== 'closed'}
aria-label="글 메뉴"
className={cx('relative cursor-pointer pt-0.5 text-[15px] leading-none font-extrabold tracking-[1px] text-(--ink3)', TAP44)}
>
⋯
</button>
)}
<button
type="button"
onClick={() => setMenu(menu === 'closed' ? 'open' : 'closed')}
aria-expanded={menu !== 'closed'}
aria-label="글 메뉴"
className={cx('relative cursor-pointer pt-0.5 text-[15px] leading-none font-extrabold tracking-[1px] text-(--ink3)', TAP44)}
>
⋯
</button>
<button type="button" onClick={toggle} aria-pressed={liked} aria-label="좋아요" className={cx('relative cursor-pointer pt-1', TAP44)}>
<HeartIcon className={cx('size-4 stroke-2', liked ? 'fill-(--heart) stroke-(--heart)' : 'fill-none stroke-(--ink3)')} />
</button>
@@ -331,7 +328,6 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
/** 이야기 탭: 쓰기 칸과 전국 최신 글 (아래로 더 받기) */
/** 피드 위 쓰는 칸. 늘 펼쳐 두고, 오늘 쓴 내 글은 바로 아래 '오늘 내 글' 묶음에 보인다 */
export function FeedComposer() {
if (IS_TOSS) return null
return (
<div className="mt-3.5">
<Composer />
@@ -406,7 +402,7 @@ export function FirstTalkCard() {
export function NearTalks({ talks, loaded }: { talks: TalkData[]; loaded: boolean }) {
if (!loaded) return null
if (talks.length) return <TalkGroup title="동네 사람들" talks={talks} />
return IS_TOSS ? null : <FirstTalkCard />
return <FirstTalkCard />
}
/** 내 정보 창의 내가 쓴 글 */