fix: pinned sidebars not updating on rename, clear tokens on auth error
Some checks failed
Automated Container Build / build-and-push (push) Failing after 1m0s
Some checks failed
Automated Container Build / build-and-push (push) Failing after 1m0s
This commit is contained in:
parent
218fb40743
commit
2152ec9a8f
3 changed files with 9 additions and 5 deletions
|
|
@ -777,6 +777,7 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
|
|||
setRenaming(null);
|
||||
setNewName('');
|
||||
loadFiles(undefined, true);
|
||||
setPinnedRefreshCounter(c => c + 1);
|
||||
showToast(`Renamed to ${finalName}`);
|
||||
}
|
||||
|
||||
|
|
@ -1958,6 +1959,7 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
|
|||
loadFiles();
|
||||
}}
|
||||
onPinChange={() => setPinnedRefreshCounter(c => c + 1)}
|
||||
onRename={() => setPinnedRefreshCounter(c => c + 1)}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex flex-1 overflow-hidden">
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ interface OfficeHomeProps {
|
|||
onFileSelect: (file: FileItem) => void;
|
||||
onCreateBlank: (file: FileItem) => void;
|
||||
onPinChange?: () => void;
|
||||
onRename?: () => void;
|
||||
}
|
||||
|
||||
// Custom Word icon (blue)
|
||||
|
|
@ -44,7 +45,7 @@ interface ContextMenuState {
|
|||
file: FileItem;
|
||||
}
|
||||
|
||||
export default function OfficeHome({ type, onFileSelect, onCreateBlank, onPinChange }: OfficeHomeProps) {
|
||||
export default function OfficeHome({ type, onFileSelect, onCreateBlank, onPinChange, onRename }: OfficeHomeProps) {
|
||||
const [recentFiles, setRecentFiles] = useState<FileItem[]>([]);
|
||||
const [pinnedFiles, setPinnedFiles] = useState<FileItem[]>([]);
|
||||
const [allFiles, setAllFiles] = useState<FileItem[]>([]);
|
||||
|
|
@ -200,6 +201,7 @@ export default function OfficeHome({ type, onFileSelect, onCreateBlank, onPinCha
|
|||
await api.rename(renaming, trimmed);
|
||||
setRenaming(null);
|
||||
fetchFiles(); // Refresh
|
||||
if (onRename) onRename();
|
||||
} catch (err: any) {
|
||||
console.error("Failed to rename", err);
|
||||
setToast({ message: err.message || "Failed to rename file", type: "error" });
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ export default function OnlyOfficeEditor({ file, type, onClose, onRename, theme,
|
|||
};
|
||||
|
||||
useEffect(() => {
|
||||
// We need a short-lived download token to pass to the Document Server
|
||||
api.createDownloadToken()
|
||||
// We need a long-lived edit token to pass to the Document Server
|
||||
api.createEditToken()
|
||||
.then((token: string) => setDownloadToken(token))
|
||||
.catch(err => {
|
||||
setLoadError("Failed to get download token");
|
||||
|
|
@ -80,8 +80,8 @@ export default function OnlyOfficeEditor({ file, type, onClose, onRename, theme,
|
|||
// the auth middleware which fails when requests come through the Next.js proxy.
|
||||
const INTERNAL_URL = process.env.NEXT_PUBLIC_API_URL || 'http://192.168.50.81:5827/api';
|
||||
|
||||
const fileUrl = `${INTERNAL_URL}/public/onlyoffice/download?path=${encodeURIComponent(file.path)}&token=${editToken}`;
|
||||
const callbackUrl = `${INTERNAL_URL}/public/onlyoffice/callback?path=${encodeURIComponent(file.path)}&token=${editToken}`;
|
||||
const fileUrl = `${INTERNAL_URL}/public/onlyoffice/download?path=${encodeURIComponent(file.path)}&token=${downloadToken}`;
|
||||
const callbackUrl = `${INTERNAL_URL}/public/onlyoffice/callback?path=${encodeURIComponent(file.path)}&token=${downloadToken}`;
|
||||
|
||||
const baseConfig: any = {
|
||||
document: {
|
||||
|
|
|
|||
Reference in a new issue