Removed unused code

Checks if recent file valid before showing
This commit is contained in:
Matthew Welch 2021-01-11 20:26:02 -08:00
parent 4096d83596
commit 6185c6181e
2 changed files with 14 additions and 59 deletions

View File

@ -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.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
app.quit();
@ -158,7 +106,7 @@ function createSplashScreen() {
splash_screen.loadFile('src/splash.html');
// Open the DevTools.
splash_screen.webContents.openDevTools();
// splash_screen.webContents.openDevTools();
// store.openInEditor();
}
@ -176,7 +124,7 @@ function createEditorWindow() {
main_window.loadFile("src/editor.html");
// Open the DevTools.
main_window.webContents.openDevTools();
// main_window.webContents.openDevTools();
return main_window;
}
@ -218,7 +166,7 @@ function openFile(file_path="", new_file=false) {
if (file_path === "") {
file_path = chooseFile("Open website data");
}
if (file_path) {
if (file_path && fs.existsSync(file_path)) {
let result = checkFile(file_path);
if (result) {
let json = getUpdatedJson(result);

View File

@ -1,13 +1,20 @@
const { ipcRenderer } = require('electron')
const { ipcRenderer } = require('electron');
const fs = require("fs");
async function showRecentFiles() {
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");
$("#splash").css("width", "100%")
} else {
for (let file of recent_files) {
let recent_file_link = $("<a>")
for (let file of valid_recent_files) {
let recent_file_link = $("<a>")
.addClass("btn list-group-item list-group-item-action")
.text(file.replace(/^.*[\\\/]/, ''))
.attr({"data-bs-toggle": "tooltip", "data-bs-placement": "bottom", "title": file})