Removed unused code
Checks if recent file valid before showing
This commit is contained in:
parent
4096d83596
commit
6185c6181e
58
src/index.js
58
src/index.js
@ -60,58 +60,6 @@ let menu_template = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
let table_col_schema = {
|
|
||||||
"id": "/table_column",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"field": {"type": "string"},
|
|
||||||
"title": {"type": "string"},
|
|
||||||
"sortable": {"type": "boolean"},
|
|
||||||
"selectable": {"type": "boolean"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let table_row_schema = {
|
|
||||||
"id": "/table_row",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"uid": {"type": "string", "pattern": /row\d+/},
|
|
||||||
},
|
|
||||||
"patternProperties": {
|
|
||||||
"column\d+": {"type": "string"}
|
|
||||||
},
|
|
||||||
"minProperties": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let table_schema = {
|
|
||||||
"id": "/table",
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {"type": "string"},
|
|
||||||
"name": {"type": "string"},
|
|
||||||
"filter": {"type": "boolean"},
|
|
||||||
"hidden": {"type": "boolean"},
|
|
||||||
"tab_name": {"type": "string"},
|
|
||||||
"description": {"type": "string"},
|
|
||||||
"columns": {"$ref": "/table_column"},
|
|
||||||
"rows": {"$ref": "/table_row"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let data_file_schema = {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"version": {"type": "string"},
|
|
||||||
"tables": {"$ref": "/table"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||||
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
|
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
|
||||||
app.quit();
|
app.quit();
|
||||||
@ -158,7 +106,7 @@ function createSplashScreen() {
|
|||||||
splash_screen.loadFile('src/splash.html');
|
splash_screen.loadFile('src/splash.html');
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
splash_screen.webContents.openDevTools();
|
// splash_screen.webContents.openDevTools();
|
||||||
// store.openInEditor();
|
// store.openInEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +124,7 @@ function createEditorWindow() {
|
|||||||
|
|
||||||
main_window.loadFile("src/editor.html");
|
main_window.loadFile("src/editor.html");
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
main_window.webContents.openDevTools();
|
// main_window.webContents.openDevTools();
|
||||||
return main_window;
|
return main_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +166,7 @@ function openFile(file_path="", new_file=false) {
|
|||||||
if (file_path === "") {
|
if (file_path === "") {
|
||||||
file_path = chooseFile("Open website data");
|
file_path = chooseFile("Open website data");
|
||||||
}
|
}
|
||||||
if (file_path) {
|
if (file_path && fs.existsSync(file_path)) {
|
||||||
let result = checkFile(file_path);
|
let result = checkFile(file_path);
|
||||||
if (result) {
|
if (result) {
|
||||||
let json = getUpdatedJson(result);
|
let json = getUpdatedJson(result);
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
const { ipcRenderer } = require('electron')
|
const { ipcRenderer } = require('electron');
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
async function showRecentFiles() {
|
async function showRecentFiles() {
|
||||||
let recent_files = await ipcRenderer.invoke("get-store-value", "recent_files");
|
let recent_files = await ipcRenderer.invoke("get-store-value", "recent_files");
|
||||||
if (recent_files.length === 0) {
|
let valid_recent_files = [];
|
||||||
|
for (let file of recent_files) {
|
||||||
|
if (fs.existsSync(file)) {
|
||||||
|
valid_recent_files.push(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (valid_recent_files.length === 0) {
|
||||||
$("#recent-files").css("display", "none");
|
$("#recent-files").css("display", "none");
|
||||||
$("#splash").css("width", "100%")
|
$("#splash").css("width", "100%")
|
||||||
} else {
|
} else {
|
||||||
for (let file of recent_files) {
|
for (let file of valid_recent_files) {
|
||||||
let recent_file_link = $("<a>")
|
let recent_file_link = $("<a>")
|
||||||
.addClass("btn list-group-item list-group-item-action")
|
.addClass("btn list-group-item list-group-item-action")
|
||||||
.text(file.replace(/^.*[\\\/]/, ''))
|
.text(file.replace(/^.*[\\\/]/, ''))
|
||||||
.attr({"data-bs-toggle": "tooltip", "data-bs-placement": "bottom", "title": file})
|
.attr({"data-bs-toggle": "tooltip", "data-bs-placement": "bottom", "title": file})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user