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