"Save" files before syncing to github
This commit is contained in:
@@ -15,3 +15,13 @@ export const saveFile = (showToast: boolean = true) => {
|
|||||||
toast.success("Saved successfully", { position: "bottom-center" });
|
toast.success("Saved successfully", { position: "bottom-center" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const saveAllFiles = () => {
|
||||||
|
const editorModels = state.editorCtx?.getModels();
|
||||||
|
state.files.forEach(file => {
|
||||||
|
const currentModel = editorModels?.find(model => model.uri.path.endsWith('/' + file.name))
|
||||||
|
if (currentModel) {
|
||||||
|
file.content = currentModel?.getValue() || '';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Octokit } from "@octokit/core";
|
|||||||
import Router from "next/router";
|
import Router from "next/router";
|
||||||
|
|
||||||
import state from '../index';
|
import state from '../index';
|
||||||
|
import { saveAllFiles } from "./saveFile";
|
||||||
|
|
||||||
const octokit = new Octokit();
|
const octokit = new Octokit();
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ export const syncToGist = async (
|
|||||||
session?: Session | null,
|
session?: Session | null,
|
||||||
createNewGist?: boolean
|
createNewGist?: boolean
|
||||||
) => {
|
) => {
|
||||||
|
saveAllFiles();
|
||||||
let files: Record<string, { filename: string; content: string }> = {};
|
let files: Record<string, { filename: string; content: string }> = {};
|
||||||
state.gistLoading = true;
|
state.gistLoading = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user