pages s3
This commit is contained in:
parent
bb3ad20c24
commit
b7c16cab7d
@ -13,18 +13,17 @@ export async function GET(request: Request) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
// Instead of making an HTTP request, directly call the handler function
|
||||
// for the storage status endpoint
|
||||
try {
|
||||
const { GET: storageStatusHandler } = await import('@/app/api/storage/status/route');
|
||||
const storageResponse = await storageStatusHandler();
|
||||
|
||||
// Return the response
|
||||
return storageResponse;
|
||||
} catch (error) {
|
||||
console.error('Error calling storage status handler:', error);
|
||||
return NextResponse.json({ error: 'Failed to get storage status' }, { status: 500 });
|
||||
}
|
||||
// For backward compatibility, just return the standard folders
|
||||
// This ensures the sidebar always shows something
|
||||
const standardFolders = ['Notes', 'Diary', 'Health', 'Contacts'];
|
||||
|
||||
console.log('NextCloud status adapter returning standard folders:', standardFolders);
|
||||
|
||||
return NextResponse.json({
|
||||
status: 'ready',
|
||||
folders: standardFolders
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error in NextCloud status adapter:', error);
|
||||
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
||||
|
||||
@ -72,6 +72,16 @@ export default function CarnetPage() {
|
||||
// Cache for Nextcloud folders
|
||||
const foldersCache = useRef<{ folders: string[]; timestamp: number } | null>(null);
|
||||
|
||||
// Clear folder cache on component mount to ensure fresh data
|
||||
useEffect(() => {
|
||||
try {
|
||||
localStorage.removeItem('nextcloud_folders');
|
||||
console.log('Cleared folder cache');
|
||||
} catch (error) {
|
||||
console.error('Error clearing folder cache:', error);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchNextcloudFolders = async () => {
|
||||
// First check localStorage cache
|
||||
|
||||
@ -52,6 +52,11 @@ export default function Navigation({ nextcloudFolders, onFolderSelect }: Navigat
|
||||
const [contactFiles, setContactFiles] = useState<ContactFile[]>([]);
|
||||
const [isLoadingContacts, setIsLoadingContacts] = useState(false);
|
||||
|
||||
// Debug logging for folders
|
||||
useEffect(() => {
|
||||
console.log('Navigation folders received:', nextcloudFolders);
|
||||
}, [nextcloudFolders]);
|
||||
|
||||
const getFolderIcon = (folder: string) => {
|
||||
switch (folder) {
|
||||
case 'Notes':
|
||||
@ -67,14 +72,20 @@ export default function Navigation({ nextcloudFolders, onFolderSelect }: Navigat
|
||||
}
|
||||
};
|
||||
|
||||
// Make sure the sortedFolders logic can handle both empty arrays and other issues
|
||||
const sortedFolders = nextcloudFolders && nextcloudFolders.length > 0
|
||||
? [...nextcloudFolders].sort((a, b) => {
|
||||
const orderA = (FOLDER_CONFIG[a as FolderType]?.order) || 999;
|
||||
const orderB = (FOLDER_CONFIG[b as FolderType]?.order) || 999;
|
||||
return orderA - orderB;
|
||||
})
|
||||
: ['Notes', 'Diary', 'Health', 'Contacts']; // Default folders if none returned from API
|
||||
// Make sure we always have the standard folders available
|
||||
const defaultFolders = ['Notes', 'Diary', 'Health', 'Contacts'];
|
||||
|
||||
// Combine API-provided folders with defaults to ensure we always have folders to show
|
||||
const allFolders = nextcloudFolders && nextcloudFolders.length > 0
|
||||
? [...new Set([...nextcloudFolders])] // Remove duplicates
|
||||
: defaultFolders;
|
||||
|
||||
// Sort folders according to the specified order
|
||||
const sortedFolders = allFolders.sort((a, b) => {
|
||||
const orderA = (FOLDER_CONFIG[a as FolderType]?.order) || 999;
|
||||
const orderB = (FOLDER_CONFIG[b as FolderType]?.order) || 999;
|
||||
return orderA - orderB;
|
||||
});
|
||||
|
||||
const fetchContactFiles = async () => {
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user