Update .gitignore, add more menu options to desktop app

Signed-off-by: Marquis Kurt <software@marquiskurt.net>
This commit is contained in:
Marquis Kurt 2019-09-17 17:08:14 -04:00
parent ee2843eff4
commit 73ad78ccba
No known key found for this signature in database
GPG Key ID: 725636D259F5402D
3 changed files with 155 additions and 4 deletions

3
.gitignore vendored
View File

@ -70,3 +70,6 @@ dist/
# Electron app files # Electron app files
desktop/*.plist desktop/*.plist
desktop/*.provisionprofile desktop/*.provisionprofile
# JetBrains IDEA directory
.idea/

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "hyperspace", "name": "hyperspace",
"version": "1.0.0-beta6", "version": "1.0.0-beta7",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -176,6 +176,19 @@ function createWindow() {
}); });
} }
/**
* Go to a URL in the main window. If it doesn't exist,
* create the window and then navigate to it.
* @param url The URL to visit in the main window
*/
function safelyGoTo(url) {
if (mainWindow == null) {
registerProtocol();
createWindow();
}
mainWindow.loadURL(url);
}
/** /**
* Create the menu bar and attach it to a window * Create the menu bar and attach it to a window
*/ */
@ -198,7 +211,22 @@ function createMenubar() {
createWindow(); createWindow();
} }
} }
} },
{
label: 'New Post',
accelerator: 'Shift+CmdOrCtrl+N',
click() {
safelyGoTo("hyperspace://hyperspace/app/#compose")
}
},
{ type: 'separator' },
{
label: 'Edit Profile',
accelerator: "Shift+CmdOrCtrl+P",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/you")
}
},
] ]
}, },
{ {
@ -218,8 +246,27 @@ function createMenubar() {
{ {
label: 'View', label: 'View',
submenu: [ submenu: [
{
label: 'Back',
accelerator: 'CmdOrCtrl+[',
click() {
if (mainWindow != null && mainWindow.webContents.canGoBack()) {
mainWindow.webContents.goBack()
}
}
},
{
label: 'Forward',
accelerator: 'CmdOrCtrl+]',
click() {
if (mainWindow != null && mainWindow.webContents.canGoForward()) {
mainWindow.webContents.goForward()
}
}
},
{ role: 'reload' }, { role: 'reload' },
{ role: 'forcereload' }, { role: 'forcereload' },
{ type: 'separator' },
{ {
label: 'Open Dev Tools', label: 'Open Dev Tools',
click () { click () {
@ -240,7 +287,51 @@ function createMenubar() {
role: 'window', role: 'window',
submenu: [ submenu: [
{ role: 'minimize' }, { role: 'minimize' },
{ role: 'close' } { role: 'close' },
{ type: 'separator' },
{
label: 'Home',
accelerator: "CmdOrCtrl+0",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/home")
}
},
{
label: 'Local',
accelerator: "CmdOrCtrl+1",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/local")
}
},
{
label: 'Public',
accelerator: "CmdOrCtrl+2",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/public")
}
},
{
label: 'Recommendations',
accelerator: "CmdOrCtrl+3",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/recommended")
}
},
{ type: 'separator' },
{
label: 'Notifications',
accelerator: "CmdOrCtrl+4",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/notifications")
}
},
{
label: 'Messages',
accelerator: "CmdOrCtrl+5",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/messages")
}
},
] ]
}, },
{ {
@ -258,7 +349,20 @@ function createMenubar() {
menuBar.unshift({ menuBar.unshift({
label: app.getName(), label: app.getName(),
submenu: [ submenu: [
{ role: 'about' }, {
label: 'About Hyperspace',
click() {
safelyGoTo("hyperspace://hyperspace/app/#/about")
}
},
{ type: 'separator' },
{
label: "Preferences...",
accelerator: 'Cmd+,',
click() {
safelyGoTo("hyperspace://hyperspace/app/#/settings");
}
},
{ type: 'separator' }, { type: 'separator' },
{ role: 'services' }, { role: 'services' },
{ type: 'separator' }, { type: 'separator' },
@ -288,6 +392,50 @@ function createMenubar() {
{ role: 'minimize' }, { role: 'minimize' },
{ role: 'zoom' }, { role: 'zoom' },
{ type: 'separator' }, { type: 'separator' },
{
label: 'Home',
accelerator: "CmdOrCtrl+0",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/home")
}
},
{
label: 'Local',
accelerator: "CmdOrCtrl+1",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/local")
}
},
{
label: 'Public',
accelerator: "CmdOrCtrl+2",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/public")
}
},
{
label: 'Recommended',
accelerator: "CmdOrCtrl+3",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/recommended")
}
},
{ type: 'separator' },
{
label: 'Notifications',
accelerator: "CmdOrCtrl+4",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/notifications")
}
},
{
label: 'Messages',
accelerator: "CmdOrCtrl+5",
click() {
safelyGoTo("hyperspace://hyperspace/app/#/messages")
}
},
{ type: 'separator' },
{ role: 'front' } { role: 'front' }
] ]
} }