<commit_before>const electron = require("electron");
const Config = require("electron-config");
const openAboutWindow = require("electron-about-window").default;
const join = require("path").join;
const app = electron.app;
const ipc = electron.ipcMain;
const BrowserWindow = electron.BrowserWindow;
const Menu = electron.Menu;

var forceQuit = false;
var mainWindow = null;

var config = new Config({
    defaults: {
        url: "https://pawoo.net/",
        bounds: {
            width: 600,
            height: 800,
        },
    }
});

app.on("window-all-closed", function () {
    if (process.platform != "darwin") {
        app.quit();
    }
});

app.on("ready", function () {
    const { width, height, x, y } = config.get('bounds');
    mainWindow = new BrowserWindow({
        title: "MstdnDeck",
        width,
        height,
        x,
        y
    });
    mainWindow.loadURL("file://" + __dirname + "/index.html");

    var menu = Menu.buildFromTemplate([
        {
            label: "MstdnDeck",
            submenu: [
                {
                    label: "About MstdnDeck", click: function () {
                        openAboutWindow({
                            icon_path: join(__dirname, "img/icon.png"),
                            copyright: "Copyright (c) 2017 Shoponpon",
                            bug_report_url: "https://pawoo.net/@shopon",
                            adjust_window_size: false,
                        });
                    }
                },
                {
                    label: "Change Instance...", click: function () {
                        showChangeInstanceWindow();
                    }
                },
                { label: "Quit", accelerator: "Command+Q", click: function () { app.quit(); } },
            ],
        },
        {
            label: "View",
            submenu: [
                { label: "Reload", accelerator: "Command+R", click: function () { 
                    mainWindow.webContents.send("reload-flag", "reload");
                } },
                { label: "Close", accelerator: "Command+W", click: function () { mainWindow.hide(); } },
            ],
        },
        {
            label: "Help",
            submenu: [
                { label: "Oepn DevTools", accelerator: "Ctrl+Shift+i", click: function(){ mainWindow.webContents.openDevTools(); }},
            ],
        }
    ]);
    Menu.setApplicationMenu(menu);

    mainWindow.on("close", function (e) {
        if (!forceQuit) {
            e.preventDefault();
            mainWindow.hide();
        }
    });

    app.on("before-quit", function (e) {
        config.set("bounds", mainWindow.getBounds());
        forceQuit = true;
    });

    app.on("activate", function () {
        mainWindow.show();
    });

    ipc.on("instance-url", (ev, url) => {
        config.set("url",url);
        mainWindow.webContents.send("instance-url", url);
    });
    
    var url = config.get("url");
    if(url == void 0){
        showChangeInstanceWindow();
    }else{
        mainWindow.webContents.on("did-finish-load",function(){
            mainWindow.webContents.send("instance-url",url);
        });
    }
});

function showChangeInstanceWindow() {<commit_msg>add the menu of Edit, and update the menu of View<commit_after>const electron = require("electron");
const Config = require("electron-config");
const openAboutWindow = require("electron-about-window").default;
const join = require("path").join;
const app = electron.app;
const ipc = electron.ipcMain;
const BrowserWindow = electron.BrowserWindow;
const Menu = electron.Menu;

var forceQuit = false;
var mainWindow = null;

var config = new Config({
    defaults: {
        url: "https://pawoo.net/",
        bounds: {
            width: 600,
            height: 800,
        },
    }
});

app.on("window-all-closed", function () {
    if (process.platform != "darwin") {
        app.quit();
    }
});

app.on("ready", function () {
    const { width, height, x, y } = config.get('bounds');
    mainWindow = new BrowserWindow({
        title: "MstdnDeck",
        width,
        height,
        x,
        y
    });
    mainWindow.loadURL("file://" + __dirname + "/index.html");

    var menu = Menu.buildFromTemplate([
        {
            label: "MstdnDeck",
            submenu: [
                {
                    label: "About MstdnDeck", click: function () {
                        openAboutWindow({
                            icon_path: join(__dirname, "img/icon.png"),
                            copyright: "Copyright (c) 2017 Shoponpon",
                            bug_report_url: "https://pawoo.net/@shopon",
                            adjust_window_size: false,
                        });
                    }
                },
                {
                    label: "Change Instance...", click: function () {
                        showChangeInstanceWindow();
                    }
                },
                { label: "Quit", accelerator: "Command+Q", click: function () { app.quit(); } },
            ],
        },
        {
            label: "Edit",
            submenu: [
                { role: "undo" },
                { role: "redo" },
                { type: "separator" },
                { role: "cut" },
                { role: "copy" },
                { role: "paste" },
                { type: "separator" },
                { role: "selectall" },
            ],
        },
        {
            label: "View",
            submenu: [
                {
                    label: "Reload", accelerator: "Command+R", click: function () {
                        mainWindow.webContents.send("reload-flag", "reload");
                    }
                },
                { label: "Close", accelerator: "Command+W", click: function () { mainWindow.hide(); } },
                { type: "separator" },
                { role: "zoomin" },
                { role: "zoomout" },
                { role: "resetzoom" }
            ],
        },
        {
            label: "Help",
            submenu: [
                { label: "Oepn DevTools", accelerator: "Ctrl+Shift+i", click: function () { mainWindow.webContents.openDevTools(); } },
            ],
        }
    ]);
    Menu.setApplicationMenu(menu);

    mainWindow.on("close", function (e) {
        if (!forceQuit) {
            e.preventDefault();
            mainWindow.hide();
        }
    });

    app.on("before-quit", function (e) {
        config.set("bounds", mainWindow.getBounds());
        forceQuit = true;
    });

    app.on("activate", function () {
        mainWindow.show();
    });

    ipc.on("instance-url", (ev, url) => {
        config.set("url", url);
        mainWindow.webContents.send("instance-url", url);
    });

    var url = config.get("url");
    if (url == void 0) {
        showChangeInstanceWindow();
    } else {
        mainWindow.webContents.on("did-finish-load", function () {
            mainWindow.webContents.send("instance-url", url);
        });
    }
});

function showChangeInstanceWindow() {
{'fraction_non_alphanumeric': 0.14929378531073445, 'fraction_numerical': 0.0031073446327683617, 'mean_word_length': 1.508324477506199, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2378270', 'n_tokens_mistral': 2014, 'n_tokens_neox': 1907, 'n_words': 381}