Compare commits

...
Author SHA1 Message Date
minaChoi 8709bfba2a docs: TODO 에 쇼츠 멈춤 버튼·토스 ait 브랜치·행사 주소·순서 의존 테스트 2026-10-28 08:56:43 +09:00
minaChoi 7f5441a512 Merge branch 'feat/youtube-shorts' — 사파리 쇼츠 시작 영상 2026-10-27 20:03:27 +09:00
minaChoi 694ea85ed3 fix: 아이폰 사파리에서 쇼츠를 누르면 첫 영상부터 열리던 문제 — 시작 영상으로 옮긴 뒤 한 번 더 맞추고, 옮기기 전엔 보이는 칸 변화를 무시 2026-10-27 20:03:27 +09:00
minaChoi ef61a5bf73 Merge branch 'feat/youtube-shorts' — 쇼츠 멈춤 없앰 2026-10-27 19:56:06 +09:00
minaChoi 74805aa829 fix: 쇼츠에서 멈춤 명령을 없앰 — 앞뒤 영상은 소리 없이 계속 틀어 두고 넘어오면 처음부터, 톡 누르면 릴스처럼 소리 켜기·끄기 (멈췄다 틀면 유튜브가 재생·멈춤 버튼을 띄워서) 2026-10-27 19:56:06 +09:00
minaChoi 5f79df1973 Merge branch 'feat/youtube-shorts' — 쇼츠 줄 재생 버튼 숨김 2026-10-27 19:45:41 +09:00
minaChoi 942b652e56 fix: 오늘 화면 쇼츠 줄 첫 카드도 재생이 시작된 뒤에만 영상을 보임 — 자동재생이 막히면 유튜브 재생 버튼 대신 표지 2026-10-27 19:45:41 +09:00
minaChoi f24e790bd7 Merge branch 'feat/youtube-shorts' — 쇼츠 토스판과 같은 코드 2026-10-27 19:30:15 +09:00
minaChoi d38cfc7229 fix: 쇼츠 코드를 토스판과 같게 — 토스도 앞뒤 미리 받기·소리 없이 자동재생, 재생 신호가 안 오는 토스만 1초 뒤 영상을 보임 (웹 동작은 그대로) 2026-10-27 19:30:15 +09:00
minaChoi b346af7fef Merge branch 'feat/youtube-shorts' — 단풍 지도 포스트 맨 앞 2026-10-27 19:05:34 +09:00
minaChoi 340b30cc8b fix: 단풍 지도를 피드 맨 위가 아니라 포스트 맨 앞으로 — 쇼츠·글쓰기·오늘의 각은 원래 자리 2026-10-27 19:05:33 +09:00
3 changed files with 75 additions and 29 deletions

No files matched your search

+4
View File
@@ -63,6 +63,10 @@
| [ ] | **[결정 필요]** 쇼츠 문구 검토: '소리 켜기'/'소리 끄기' (줄 제목은 없앰) | 화면 문구 규칙 | `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` |
+64 -26
View File
@@ -37,6 +37,11 @@ function useTabBarHeight() {
const YT_ORIGIN = 'https://www.youtube-nocookie.com'
// 토스 웹뷰에는 플레이어가 보내는 재생 상태가 오지 않는다. 그래서 토스는 첫 장면이 나왔는지를 시간으로 보고 표지를 걷는다 (나머지는 웹과 같다)
const PLAIN = IS_TOSS
// 토스는 재생 상태가 안 오므로, 플레이어 문서가 뜨고 이만큼 지나면 첫 장면이 나왔다고 보고 표지를 걷는다 (그 전엔 플레이어의 검은 화면 대신 표지)
const PLAIN_SHOW_MS = 1000
function embed(id: string) {
const q = new URLSearchParams({
autoplay: '1', mute: '1', playsinline: '1', loop: '1', playlist: id, controls: '0', rel: '0', modestbranding: '1',
@@ -45,7 +50,7 @@ function embed(id: string) {
return `${YT_ORIGIN}/embed/${id}?${q}`
}
type Func = 'playVideo' | 'pauseVideo' | 'seekTo' | 'mute' | 'unMute'
type Func = 'playVideo' | 'seekTo' | 'mute' | 'unMute'
/** 이미 띄운 플레이어에 명령 (IFrame API 메시지) */
function command(frame: HTMLIFrameElement | null | undefined, func: Func, args: unknown[] = []) {
@@ -101,16 +106,35 @@ 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}
className="pointer-events-none absolute top-1/2 left-1/2 border-0"
// 재생 상태를 받으려면 플레이어에 먼저 '듣고 있다'고 알린다
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')}
style={{ width: PLAYER_W, height: (PLAYER_W * 16) / 9, transform: `translate(-50%, -50%) scale(${SCALE})` }}
/>
)}
@@ -147,22 +171,37 @@ 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 frames = useRef(new Map<number, HTMLIFrameElement>())
const atRef = useRef(start)
const soundRef = useRef(false)
// 누르기로 멈춘 상태. 다른 영상으로 넘어가면 다시 재생 중으로
const paused = useRef(false)
// 처음 한 번: 시작 영상으로 맞추고, 뒤 페이지 스크롤을 잠근다
const startRef = useRef(start)
useEffect(() => {
// scrollIntoView 는 바깥 칸까지 굴려 버튼 줄이 헤더 밑으로 숨으므로 목록만 옮긴다
// 시작 영상으로 옮기기 전엔 보이는 칸이 바뀐 것으로 치지 않는다 (사파리는 처음 그릴 때 맨 위 칸이 먼저 보여 첫 영상으로 바뀌던 것)
const placed = useRef(false)
useLayoutEffect(() => {
// scrollIntoView 는 바깥 칸까지 굴려 버튼 줄이 헤더 밑으로 숨으므로 목록만 옮긴다. 사파리는 첫 그림 전에 옮긴 값을 되돌려 한 번 더
const box = list.current
if (box) box.scrollTop = box.clientHeight * startRef.current
const place = () => {
if (box) box.scrollTop = box.clientHeight * startRef.current
}
place()
const raf = requestAnimationFrame(() => {
place()
placed.current = true
})
const root = document.documentElement
const before = root.style.overflow
root.style.overflow = 'hidden'
return () => {
cancelAnimationFrame(raf)
root.style.overflow = before
}
}, [])
@@ -178,6 +217,7 @@ 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 },
@@ -186,7 +226,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
@@ -200,9 +240,6 @@ 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)
@@ -213,27 +250,21 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
useEffect(() => {
if (atRef.current !== at) moved(items[at])
atRef.current = at
paused.current = false
// 앞뒤 영상은 소리 없이 계속 돌고 있으니, 넘어온 영상만 처음부터 다시 틀고 소리를 맞춘다 (멈춤 명령은 쓰지 않는다)
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, 'pauseVideo')
command(f, 'mute')
}
} else 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
@@ -256,7 +287,7 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
drag.current = null
setDragging(false)
if (!d || !box) return
if (!d.moved) return togglePause()
if (!d.moved) return toggleSound()
// 30px 만 끌어도 다음·이전 영상으로, 그보다 덜 끌면 제자리로
const h = box.clientHeight
const dy = e.clientY - d.y
@@ -303,8 +334,8 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
<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" />
{/* 웹은 앞뒤 영상까지 미리 띄워 넘길 때 깜빡이지 않게, 토스 앱은 무거워 지금 영상 하나만 */}
{(IS_TOSS ? i === at : Math.abs(i - at) <= 1) && (
{/* 릴스처럼 앞뒤 영상을 소리 없이 미리 받아 둔다 */}
{Math.abs(i - at) <= 1 && (
<iframe
ref={(f) => {
if (f) frames.current.set(i, f)
@@ -315,6 +346,13 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
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)
}
e.currentTarget.contentWindow?.postMessage(JSON.stringify({ event: 'listening', id: s.id }), YT_ORIGIN)
// 앞뒤 밖으로 밀려나 내려갔다 다시 뜬 플레이어는 첫 장면을 새로 받을 때까지 다시 숨긴다
setReady((r) => {
@@ -324,7 +362,7 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
return next
})
}}
className={cx('absolute inset-0 size-full border-0 transition-opacity duration-200', !IS_TOSS && !ready.has(i) && 'opacity-0')}
className={cx('absolute inset-0 size-full border-0 transition-opacity duration-200', (PLAIN ? !plainShown.has(i) : !ready.has(i)) && 'opacity-0')}
/>
)}
<div
@@ -336,7 +374,7 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
drag.current = null
setDragging(false)
}}
onClick={() => lastPointer.current !== 'mouse' && togglePause()}
onClick={() => lastPointer.current !== 'mouse' && toggleSound()}
className={cx('absolute inset-0 touch-pan-y select-none', dragging ? 'cursor-grabbing' : 'cursor-grab')}
/>
</div>
+7 -3
View File
@@ -636,9 +636,6 @@ export function TodayPage() {
// 피드 칸은 전국 공통이라 지역이 바뀌어도 글 번호가 같다. 지역마다 새로 그려 넘긴 슬라이드·펼친 상태가 남지 않게 한다
<section key={region.code} aria-label="오늘" aria-busy={load === 'loading'} className={cx('transition-opacity', feed.isPlaceholderData && 'opacity-60')}>
<Hero hero={f?.hero} post={f?.hero_post} today={today.data} ranked={stories} all={f?.stories ?? []} feedLoad={load} todayLoad={loadOf(today)} />
{/* 단풍철엔 단풍 지도를 피드 맨 위에, 단풍 이야기 묶음은 바로 아래 */}
<FoliageCard />
{group(TalkTopic.FOLIAGE)}
<ShortsRail />
<FeedComposer />
{mine.length > 0 && <TalkGroup title="오늘 내 글" talks={mine} href="/talk?mine=1" />}
@@ -660,6 +657,13 @@ export function TodayPage() {
{load !== 'loading' && !posts.length && (
<StateBox load="ready" empty={load === 'ready' ? '오늘 올라온 글이 아직 없어요.' : '글을 불러오지 못했어요.'} hold={<PostsSkel />} className="inset-x-3 top-3.5 bottom-auto" />
)}
{/* 단풍철엔 단풍 지도를 포스트 맨 앞에, 단풍 이야기 묶음은 바로 아래 */}
{load !== 'loading' && posts.length > 0 && (
<>
<FoliageCard />
{group(TalkTopic.FOLIAGE)}
</>
)}
{posts.map((p, i) => (
<Fragment key={p.post_id}>
<PostCard post={p} />