fix trashing in rooms
This commit is contained in:
@@ -49,6 +49,9 @@ class RoomManager {
|
||||
await this.fileManager.fetchFiles();
|
||||
console.log('[RoomManager] Files fetched');
|
||||
|
||||
// Render breadcrumb after files are fetched
|
||||
this.viewManager.renderBreadcrumb();
|
||||
|
||||
console.log('[RoomManager] Initializing search...');
|
||||
// Initialize search
|
||||
this.searchManager.initialize();
|
||||
@@ -65,11 +68,42 @@ class RoomManager {
|
||||
}
|
||||
}
|
||||
|
||||
navigateToFolder(folderName) {
|
||||
console.log('[RoomManager] Navigating to folder:', folderName);
|
||||
const newPath = this.currentPath ? `${this.currentPath}/${folderName}` : folderName;
|
||||
this.navigateTo(newPath);
|
||||
}
|
||||
|
||||
navigateToParent() {
|
||||
console.log('[RoomManager] Navigating to parent folder');
|
||||
if (!this.currentPath) return;
|
||||
|
||||
const parts = this.currentPath.split('/');
|
||||
parts.pop(); // Remove the last part
|
||||
const newPath = parts.join('/');
|
||||
this.navigateTo(newPath);
|
||||
}
|
||||
|
||||
navigateTo(path) {
|
||||
console.log('[RoomManager] Navigating to path:', path);
|
||||
this.currentPath = path;
|
||||
// Update the URL with the current path
|
||||
const url = new URL(window.location);
|
||||
if (this.currentPath) {
|
||||
url.searchParams.set('path', this.currentPath);
|
||||
} else {
|
||||
url.searchParams.delete('path');
|
||||
}
|
||||
window.history.replaceState({}, '', url);
|
||||
this.fileManager.fetchFiles().then(() => {
|
||||
// Render breadcrumb after files are fetched
|
||||
this.viewManager.renderBreadcrumb();
|
||||
});
|
||||
}
|
||||
|
||||
getPathFromUrl() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const path = urlParams.get('path') || '';
|
||||
console.log('[RoomManager] Getting path from URL:', path);
|
||||
return path;
|
||||
return urlParams.get('path') || '';
|
||||
}
|
||||
|
||||
initializeEventListeners() {
|
||||
@@ -117,54 +151,18 @@ class RoomManager {
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the room manager when the script loads
|
||||
function initializeRoom() {
|
||||
console.log('[RoomManager] Starting room initialization...');
|
||||
// Initialize the room manager when the DOM is loaded
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const config = {
|
||||
roomId: document.querySelector('meta[name="room-id"]').getAttribute('content'),
|
||||
canDelete: document.querySelector('meta[name="can-delete"]').getAttribute('content') === 'true',
|
||||
canShare: document.querySelector('meta[name="can-share"]').getAttribute('content') === 'true',
|
||||
canUpload: document.querySelector('meta[name="can-upload"]').getAttribute('content') === 'true',
|
||||
canDownload: document.querySelector('meta[name="can-download"]').getAttribute('content') === 'true',
|
||||
canRename: document.querySelector('meta[name="can-rename"]').getAttribute('content') === 'true',
|
||||
canMove: document.querySelector('meta[name="can-move"]').getAttribute('content') === 'true'
|
||||
};
|
||||
|
||||
try {
|
||||
// Wait for all meta tags to be available
|
||||
const requiredMetaTags = [
|
||||
'room-id',
|
||||
'can-delete',
|
||||
'can-share',
|
||||
'can-upload',
|
||||
'can-download',
|
||||
'can-rename',
|
||||
'can-move'
|
||||
];
|
||||
|
||||
console.log('[RoomManager] Checking required meta tags...');
|
||||
const missingTags = requiredMetaTags.filter(tag => !document.querySelector(`meta[name="${tag}"]`));
|
||||
|
||||
if (missingTags.length > 0) {
|
||||
console.error('[RoomManager] Missing required meta tags:', missingTags);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[RoomManager] All meta tags found, creating config...');
|
||||
const config = {
|
||||
roomId: document.querySelector('meta[name="room-id"]').getAttribute('content'),
|
||||
canDelete: document.querySelector('meta[name="can-delete"]').getAttribute('content') === 'true',
|
||||
canShare: document.querySelector('meta[name="can-share"]').getAttribute('content') === 'true',
|
||||
canUpload: document.querySelector('meta[name="can-upload"]').getAttribute('content') === 'true',
|
||||
canDownload: document.querySelector('meta[name="can-download"]').getAttribute('content') === 'true',
|
||||
canRename: document.querySelector('meta[name="can-rename"]').getAttribute('content') === 'true',
|
||||
canMove: document.querySelector('meta[name="can-move"]').getAttribute('content') === 'true'
|
||||
};
|
||||
|
||||
console.log('[RoomManager] Config created:', config);
|
||||
window.roomManager = new RoomManager(config);
|
||||
} catch (error) {
|
||||
console.error('[RoomManager] Error during initialization:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for DOM to be fully loaded
|
||||
if (document.readyState === 'loading') {
|
||||
console.log('[RoomManager] DOM still loading, waiting for DOMContentLoaded...');
|
||||
document.addEventListener('DOMContentLoaded', initializeRoom);
|
||||
} else {
|
||||
console.log('[RoomManager] DOM already loaded, initializing with delay...');
|
||||
// If DOM is already loaded, wait a bit to ensure all scripts are loaded
|
||||
setTimeout(initializeRoom, 0);
|
||||
}
|
||||
// Create and expose the room manager instance
|
||||
window.roomManager = new RoomManager(config);
|
||||
});
|
||||
Reference in New Issue
Block a user