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'); ...@@ -4,6 +4,7 @@ const isDev = require('electron-is-dev');
let win; let win;
let deeplinkingUrl; let deeplinkingUrl;
let deeplinkingType;
const gotTheLock = app.requestSingleInstanceLock(); const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) { if (!gotTheLock) {
...@@ -18,13 +19,25 @@ function executeDeeplink(commandLine) { ...@@ -18,13 +19,25 @@ function executeDeeplink(commandLine) {
if (process.platform == 'win32') { if (process.platform == 'win32') {
let commandLineString = commandLine.slice(1) + ''; let commandLineString = commandLine.slice(1) + '';
let commandLineArgs = commandLineString.split(","); 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) {
if (win.isMinimized()) win.restore(); if (win.isMinimized()) win.restore();
win.focus(); 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) { ...@@ -70,8 +83,8 @@ app.on('open-url', function (event, url) {
deeplinkingUrl = url; deeplinkingUrl = url;
}); });
const PROTOCOL_PREFIX_SONG = "spinshare-song"; app.setAsDefaultProtocolClient("spinshare-song");
app.setAsDefaultProtocolClient(PROTOCOL_PREFIX_SONG); app.setAsDefaultProtocolClient("spinshare-user");
ipcMain.on("download", (event, info) => { ipcMain.on("download", (event, info) => {
console.log("Download Request Received"); console.log("Download Request Received");
......
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
"protocols": { "protocols": {
"name": "spinshare-song-deeplink", "name": "spinshare-song-deeplink",
"schemes": [ "schemes": [
"spinshare-song" "spinshare-song",
"spinshare-user"
] ]
}, },
"dmg": { "dmg": {
......
...@@ -87,6 +87,8 @@ function NavigateToSongDetail(songId) { ...@@ -87,6 +87,8 @@ function NavigateToSongDetail(songId) {
} }
function NavigateToUser(userId) { function NavigateToUser(userId) {
console.log("Loading User " + userId);
// Stop audio if playing // Stop audio if playing
SongDetailStopPreview(); SongDetailStopPreview();
......
// Protocol // Protocol
ipcRenderer.on("protocol-to-songdetail", (event, info) => {
console.log(info);
});
if(process.argv.length > 1) { if(process.argv.length > 1) {
if(process.argv[1].includes("spinshare-song")) { if(process.argv[1].includes("spinshare-song")) {
let songId = process.argv[1].replace("spinshare-song://", "").replace("/", ""); let songId = process.argv[1].replace("spinshare-song://", "").replace("/", "");
NavigateToSongDetail(songId); 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