fix: 봇 상태 표시 및 일정 추가 애니메이션 개선
- 봇 lastAddedCount를 실제 추가시에만 업데이트 (0으로 덮어쓰지 않음) - 일정 추가 폼 애니메이션 타이밍 개선 (첫 로딩: 딜레이, 카테고리 변경: 즉시) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1a9fa54981
commit
2d469739b7
2 changed files with 30 additions and 25 deletions
|
|
@ -72,13 +72,17 @@ async function schedulerPlugin(fastify, opts) {
|
||||||
try {
|
try {
|
||||||
const result = await syncFn(bot);
|
const result = await syncFn(bot);
|
||||||
const status = await getStatus(botId);
|
const status = await getStatus(botId);
|
||||||
await updateStatus(botId, {
|
const updateData = {
|
||||||
status: 'running',
|
status: 'running',
|
||||||
lastCheckAt: new Date().toISOString(),
|
lastCheckAt: new Date().toISOString(),
|
||||||
lastAddedCount: result.addedCount,
|
|
||||||
totalAdded: (status.totalAdded || 0) + result.addedCount,
|
totalAdded: (status.totalAdded || 0) + result.addedCount,
|
||||||
errorMessage: null,
|
errorMessage: null,
|
||||||
});
|
};
|
||||||
|
// 실제로 추가된 경우에만 lastAddedCount 업데이트
|
||||||
|
if (result.addedCount > 0) {
|
||||||
|
updateData.lastAddedCount = result.addedCount;
|
||||||
|
}
|
||||||
|
await updateStatus(botId, updateData);
|
||||||
fastify.log.info(`[${botId}] 동기화 완료: ${result.addedCount}개 추가`);
|
fastify.log.info(`[${botId}] 동기화 완료: ${result.addedCount}개 추가`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await updateStatus(botId, {
|
await updateStatus(botId, {
|
||||||
|
|
@ -98,11 +102,15 @@ async function schedulerPlugin(fastify, opts) {
|
||||||
try {
|
try {
|
||||||
const result = await syncFn(bot);
|
const result = await syncFn(bot);
|
||||||
const status = await getStatus(botId);
|
const status = await getStatus(botId);
|
||||||
await updateStatus(botId, {
|
const updateData = {
|
||||||
lastCheckAt: new Date().toISOString(),
|
lastCheckAt: new Date().toISOString(),
|
||||||
lastAddedCount: result.addedCount,
|
|
||||||
totalAdded: (status.totalAdded || 0) + result.addedCount,
|
totalAdded: (status.totalAdded || 0) + result.addedCount,
|
||||||
});
|
};
|
||||||
|
// 실제로 추가된 경우에만 lastAddedCount 업데이트
|
||||||
|
if (result.addedCount > 0) {
|
||||||
|
updateData.lastAddedCount = result.addedCount;
|
||||||
|
}
|
||||||
|
await updateStatus(botId, updateData);
|
||||||
fastify.log.info(`[${botId}] 초기 동기화 완료: ${result.addedCount}개 추가`);
|
fastify.log.info(`[${botId}] 초기 동기화 완료: ${result.addedCount}개 추가`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
fastify.log.error(`[${botId}] 초기 동기화 오류: ${err.message}`);
|
fastify.log.error(`[${botId}] 초기 동기화 오류: ${err.message}`);
|
||||||
|
|
|
||||||
|
|
@ -29,20 +29,6 @@ const itemVariants = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const formVariants = {
|
|
||||||
hidden: { opacity: 0, y: 20 },
|
|
||||||
visible: {
|
|
||||||
opacity: 1,
|
|
||||||
y: 0,
|
|
||||||
transition: { duration: 0.3, ease: "easeOut", delay: 0.3 },
|
|
||||||
},
|
|
||||||
exit: {
|
|
||||||
opacity: 0,
|
|
||||||
y: -10,
|
|
||||||
transition: { duration: 0.2 },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// 카테고리 ID 상수
|
// 카테고리 ID 상수
|
||||||
const CATEGORY_IDS = {
|
const CATEGORY_IDS = {
|
||||||
YOUTUBE: 2,
|
YOUTUBE: 2,
|
||||||
|
|
@ -59,6 +45,7 @@ function ScheduleFormPage() {
|
||||||
const [categories, setCategories] = useState([]);
|
const [categories, setCategories] = useState([]);
|
||||||
const [selectedCategory, setSelectedCategory] = useState(null);
|
const [selectedCategory, setSelectedCategory] = useState(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [isInitialLoad, setIsInitialLoad] = useState(true);
|
||||||
|
|
||||||
// 카테고리 로드
|
// 카테고리 로드
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -160,7 +147,10 @@ function ScheduleFormPage() {
|
||||||
<CategorySelector
|
<CategorySelector
|
||||||
categories={categories}
|
categories={categories}
|
||||||
selectedId={selectedCategory}
|
selectedId={selectedCategory}
|
||||||
onChange={setSelectedCategory}
|
onChange={(id) => {
|
||||||
|
setSelectedCategory(id);
|
||||||
|
setIsInitialLoad(false);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
|
|
@ -168,10 +158,17 @@ function ScheduleFormPage() {
|
||||||
<AnimatePresence mode="wait">
|
<AnimatePresence mode="wait">
|
||||||
<motion.div
|
<motion.div
|
||||||
key={selectedCategory}
|
key={selectedCategory}
|
||||||
variants={formVariants}
|
initial={{ opacity: 0, y: 10 }}
|
||||||
initial="hidden"
|
animate={{
|
||||||
animate="visible"
|
opacity: 1,
|
||||||
exit="exit"
|
y: 0,
|
||||||
|
transition: {
|
||||||
|
duration: isInitialLoad ? 0.4 : 0.15,
|
||||||
|
ease: "easeOut",
|
||||||
|
delay: isInitialLoad ? 0.3 : 0,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
exit={{ opacity: 0, y: -10, transition: { duration: 0.1 } }}
|
||||||
>
|
>
|
||||||
{renderForm()}
|
{renderForm()}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue