Commit b2549b86 authored by Andreas Heimann's avatar Andreas Heimann

added spinshare-user deeplink

parent b8b733b9
......@@ -4,6 +4,7 @@ const isDev = require('electron-is-dev');
let win;
let deeplinkingUrl;
let deeplinkingType;
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
......@@ -18,13 +19,25 @@ function executeDeeplink(commandLine) {
if (process.platform == 'win32') {
let commandLineString = commandLine.slice(1) + '';
let commandLineArgs = commandLineString.split(",");
deeplinkingUrl = commandLineArgs[commandLineArgs.length - 1].replace("spinshare-song://", "").replace("/", "");
let fullCommand = commandLineArgs[commandLineArgs.length - 1];
if(fullCommand.includes("spinshare-song")) {
deeplinkingType = "song";
deeplinkingUrl = fullCommand.replace("spinshare-song://", "").replace("/", "");
} else if(fullCommand.includes("spinshare-user")) {
deeplinkingType = "user";
deeplinkingUrl = fullCommand.replace("spinshare-user://", "").replace("/", "");
}
}
if (win) {
if (win.isMinimized()) win.restore();
win.focus();
win.webContents.executeJavaScript(`NavigateToSongDetail("${deeplinkingUrl}")`);
if(deeplinkingType == "song") {
win.webContents.executeJavaScript(`NavigateToSongDetail("${deeplinkingUrl}")`);
} else if(deeplinkingType == "user") {
win.webContents.executeJavaScript(`NavigateToUser("${deeplinkingUrl}")`);
}
}
}
......@@ -70,8 +83,8 @@ app.on('open-url', function (event, url) {
deeplinkingUrl = url;
});
const PROTOCOL_PREFIX_SONG = "spinshare-song";
app.setAsDefaultProtocolClient(PROTOCOL_PREFIX_SONG);
app.setAsDefaultProtocolClient("spinshare-song");
app.setAsDefaultProtocolClient("spinshare-user");
ipcMain.on("download", (event, info) => {
console.log("Download Request Received");
......
......@@ -31,7 +31,8 @@
"protocols": {
"name": "spinshare-song-deeplink",
"schemes": [
"spinshare-song"
"spinshare-song",
"spinshare-user"
]
},
"dmg": {
......
......@@ -87,6 +87,8 @@ function NavigateToSongDetail(songId) {
}
function NavigateToUser(userId) {
console.log("Loading User " + userId);
// Stop audio if playing
SongDetailStopPreview();
......
// Protocol
ipcRenderer.on("protocol-to-songdetail", (event, info) => {
console.log(info);
});
if(process.argv.length > 1) {
if(process.argv[1].includes("spinshare-song")) {
let songId = process.argv[1].replace("spinshare-song://", "").replace("/", "");
NavigateToSongDetail(songId);
} else if(process.argv[1].includes("spinshare-user")) {
let userId = process.argv[1].replace("spinshare-user://", "").replace("/", "");
NavigateToUser(userId);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment