Skip to content

Commit 96fef94

Browse files
committed
Don't try to use the contents of the file as the file name when using the save shortcut... closes pterodactyl#2266
1 parent 9e60cf9 commit 96fef94

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

resources/scripts/components/elements/AceEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface Props {
2828
filename?: string;
2929
onModeChanged: (mode: string) => void;
3030
fetchContent: (callback: () => Promise<string>) => void;
31-
onContentSaved: (content: string) => void;
31+
onContentSaved: () => void;
3232
}
3333

3434
export default ({ style, initialContent, filename, mode, fetchContent, onContentSaved, onModeChanged }: Props) => {
@@ -70,7 +70,7 @@ export default ({ style, initialContent, filename, mode, fetchContent, onContent
7070
editor.commands.addCommand({
7171
name: 'Save',
7272
bindKey: { win: 'Ctrl-s', mac: 'Command-s' },
73-
exec: (editor: Editor) => onContentSaved(editor.session.getValue()),
73+
exec: () => onContentSaved(),
7474
});
7575

7676
fetchContent(() => Promise.resolve(editor.session.getValue()));

resources/scripts/components/server/files/FileEditContainer.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ export default () => {
3535

3636
let fetchFileContent: null | (() => Promise<string>) = null;
3737

38-
if (action !== 'new') {
39-
useEffect(() => {
40-
setLoading(true);
41-
setError('');
42-
getFileContents(uuid, hash.replace(/^#/, ''))
43-
.then(setContent)
44-
.catch(error => {
45-
console.error(error);
46-
setError(httpErrorToHuman(error));
47-
})
48-
.then(() => setLoading(false));
49-
}, [ uuid, hash ]);
50-
}
38+
useEffect(() => {
39+
if (action === 'new') return;
40+
41+
setLoading(true);
42+
setError('');
43+
getFileContents(uuid, hash.replace(/^#/, ''))
44+
.then(setContent)
45+
.catch(error => {
46+
console.error(error);
47+
setError(httpErrorToHuman(error));
48+
})
49+
.then(() => setLoading(false));
50+
}, [ action, uuid, hash ]);
5151

5252
const save = (name?: string) => {
5353
if (!fetchFileContent) {

0 commit comments

Comments
 (0)