mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 08:23:35 +00:00
clear cache properly and without hacky window reload
This commit is contained in:
1 parent
d72fc80cc5
commit
114eb13ce6
3 files changed
+33
-15
No files matched your search
@@ -9,10 +9,10 @@ import { Separator } from '@/components/ui/separator';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
|
||||
interface DMStatusInfoProps {
|
||||
clearCache?: () => Promise<void>;
|
||||
clearCacheAndReload?: () => Promise<void>;
|
||||
}
|
||||
|
||||
export const DMStatusInfo = ({ clearCache }: DMStatusInfoProps) => {
|
||||
export const DMStatusInfo = ({ clearCacheAndReload }: DMStatusInfoProps) => {
|
||||
const [isClearing, setIsClearing] = useState(false);
|
||||
const { toast } = useToast();
|
||||
const {
|
||||
@@ -25,19 +25,16 @@ export const DMStatusInfo = ({ clearCache }: DMStatusInfoProps) => {
|
||||
} = useDMContext();
|
||||
|
||||
const handleClearCache = async () => {
|
||||
if (!clearCache) return;
|
||||
if (!clearCacheAndReload) return;
|
||||
|
||||
setIsClearing(true);
|
||||
try {
|
||||
await clearCache();
|
||||
await clearCacheAndReload();
|
||||
toast({
|
||||
title: 'Cache cleared',
|
||||
description: 'All cached messages have been removed. Reloading...',
|
||||
description: 'Reloading messages from relays...',
|
||||
});
|
||||
// Give user time to see the toast
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
setIsClearing(false);
|
||||
} catch (error) {
|
||||
console.error('Error clearing cache:', error);
|
||||
toast({
|
||||
@@ -180,7 +177,7 @@ export const DMStatusInfo = ({ clearCache }: DMStatusInfoProps) => {
|
||||
</Card>
|
||||
|
||||
{/* Actions */}
|
||||
{clearCache && (
|
||||
{clearCacheAndReload && (
|
||||
<>
|
||||
<Separator />
|
||||
<div className="space-y-3">
|
||||
|
||||
Reference in new issue
Block a user