fix: resolve danmaku ttl fetch error and improve frontend visibility
parent
b095ada2ea
commit
4b214980cf
|
|
@ -17,9 +17,11 @@ class DanmakuService:
|
|||
async def get_ttl(self, db: AsyncSession) -> int:
|
||||
"""Fetch TTL from system settings or use default"""
|
||||
try:
|
||||
setting = await system_settings_service.get_setting_by_key("danmaku_ttl", db)
|
||||
setting = await system_settings_service.get_setting("danmaku_ttl", db)
|
||||
if setting:
|
||||
return int(setting.value)
|
||||
val = int(setting.value)
|
||||
# logger.info(f"Using configured danmaku_ttl: {val}")
|
||||
return val
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to fetch danmaku_ttl: {e}")
|
||||
return self.default_ttl
|
||||
|
|
@ -33,6 +35,8 @@ class DanmakuService:
|
|||
now = time.time()
|
||||
ttl = await self.get_ttl(db)
|
||||
expire_time = now - ttl
|
||||
|
||||
logger.info(f"Adding danmaku: '{text}' at {now}, ttl={ttl}, expire_threshold={expire_time}")
|
||||
|
||||
# Create message object
|
||||
# Add unique timestamp/random to value to ensure uniqueness in Set if user spams same msg?
|
||||
|
|
@ -82,6 +86,8 @@ class DanmakuService:
|
|||
# ZRANGEBYSCORE key min max
|
||||
results = await redis_cache.client.zrangebyscore(self.redis_key, min_score, "+inf")
|
||||
|
||||
logger.debug(f"Fetching danmaku: found {len(results)} messages (since {min_score})")
|
||||
|
||||
messages = []
|
||||
for res in results:
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ export function DanmakuLayer({ enabled }: DanmakuLayerProps) {
|
|||
});
|
||||
|
||||
if (newMessages.length > 0) {
|
||||
console.log(`[Danmaku] Received ${newMessages.length} new messages`, newMessages);
|
||||
newMessages.forEach((msg: DanmakuMessage) => processedIds.current.add(msg.id));
|
||||
// Add to queue
|
||||
addMessagesToTrack(newMessages);
|
||||
|
|
@ -83,7 +84,7 @@ export function DanmakuLayer({ enabled }: DanmakuLayerProps) {
|
|||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className="absolute inset-0 pointer-events-none z-30 overflow-hidden"
|
||||
className="absolute inset-0 pointer-events-none z-50 overflow-hidden"
|
||||
style={{ userSelect: 'none' }}
|
||||
>
|
||||
{visibleMessages.map(msg => (
|
||||
|
|
@ -93,8 +94,8 @@ export function DanmakuLayer({ enabled }: DanmakuLayerProps) {
|
|||
style={{
|
||||
top: `${msg.top}%`,
|
||||
left: '100%',
|
||||
fontSize: '1.2rem',
|
||||
textShadow: '0 0 4px rgba(0,0,0,0.8)',
|
||||
fontSize: '1.5rem', // Increased size for visibility
|
||||
textShadow: '0 0 4px rgba(0,0,0,0.8), 0 0 2px rgba(0,0,0,1)', // Stronger shadow
|
||||
animation: `danmaku-move ${msg.duration}s linear forwards`
|
||||
}}
|
||||
onAnimationEnd={() => handleAnimationEnd(msg.id)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue