Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
solvedDev committed Jan 5, 2019
1 parent 79cad76 commit c67c14c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/renderer/components/sidebar/content/Explorer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
FileDisplayer
},
created() {
this.$root.$on("refreshExplorer", () => {
this.refresh();
});
ipcRenderer.on("readDir", (event, args) => {
this.directory = args.files;
Expand All @@ -74,6 +78,7 @@
this.listeners.forEach(e => {
ipcRenderer.removeAllListeners(e);
});
this.$root.$off("refreshExplorer");
},
data() {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (!process.env.IS_WEB) Vue.use(require('vue-electron'));
Vue.config.productionTip = false;

/* eslint-disable no-new */
new Vue({
export default new Vue({
components: { App },
store,
template: '<App/>'
Expand Down
17 changes: 14 additions & 3 deletions src/renderer/scripts/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import fs from "fs";
import mkdirp from "mkdirp";
import dirToJson from "dir-to-json";
import { base_path, mojang_path } from "./constants.js";
import Store from "../store/index";
import Vue from "../main";

class FileSystem {
save(path, content) {
save(path, content, update=false, open=false) {
let tmp_path = this.getPath(path).split("/");
tmp_path.pop();
tmp_path = tmp_path.join("/");
Expand All @@ -13,13 +15,22 @@ class FileSystem {

fs.writeFile(this.getPath(path), content, (err) => {
if(err) console.log(err);

if(update) {
Vue.$root.$emit("refreshExplorer");
}
if(open) {
Store.commit("addToTabSystem", {
content,
file: path.split("/").pop(),
path
});
}
});
});
}

getPath(path) {
console.log(base_path);

return base_path + path;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/windows/createFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default class CreateFileWindow extends ContentWindow {
}, -3, 1);

this.createFile = () => {
FileSystem.save(this.current_content.getPath(), "");
FileSystem.save(this.current_content.getPath(), "", true, true);
this.close();
};
this.actions = [
Expand Down

0 comments on commit c67c14c

Please sign in to comment.