fix: (web) restore quest table loading logic
- Simplify component by removing complex state management - Show skeleton only during initial load, content otherwise - Keep refresh icon spin during manual refresh
This commit is contained in:
@@ -213,21 +213,6 @@ function QuestTableContent({ quests }: { quests: QuestListItem[] }) {
|
||||
|
||||
export function QuestTable({ quests, isLoading, onRefresh }: QuestTableProps) {
|
||||
const [isRefreshing, setIsRefreshing] = React.useState(false);
|
||||
const previousQuestsRef = React.useRef<QuestListItem[]>(quests);
|
||||
const [displayQuests, setDisplayQuests] = React.useState<QuestListItem[]>(quests);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (isLoading) {
|
||||
setIsRefreshing(true);
|
||||
} else {
|
||||
setIsRefreshing(false);
|
||||
previousQuestsRef.current = quests;
|
||||
if (quests.length !== previousQuestsRef.current.length ||
|
||||
JSON.stringify(quests) !== JSON.stringify(previousQuestsRef.current)) {
|
||||
setDisplayQuests(quests);
|
||||
}
|
||||
}
|
||||
}, [isLoading, quests]);
|
||||
|
||||
const handleRefresh = async () => {
|
||||
setIsRefreshing(true);
|
||||
@@ -286,7 +271,7 @@ export function QuestTable({ quests, isLoading, onRefresh }: QuestTableProps) {
|
||||
{isLoading ? (
|
||||
<QuestTableSkeleton />
|
||||
) : (
|
||||
<QuestTableContent quests={displayQuests} />
|
||||
<QuestTableContent quests={quests} />
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user