Skip to content

Commit 8e1c0f7

Browse files
committed
improved link card share for media cards
1 parent 3e32ffa commit 8e1c0f7

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

www/scripts/sepiaFW.webSocket.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -851,38 +851,46 @@ function sepiaFW_build_webSocket_client(sepiaSessionId){
851851
}
852852
//console.log(shareData);
853853
if (shareData.type && shareData.data){
854+
var sdd = shareData.data;
854855
var ask;
855856
//give more info
856857
if (shareData.type == SepiaFW.client.SHARE_TYPE_LINK){
857858
//Link
858-
ask = "<p><b>" + SepiaFW.local.g('link_open_url') + "</b></p>";
859-
ask += "<b>URL:</b> ";
860-
if (shareData.data.url){
861-
ask += (shareData.data.url.length > 30)? (shareData.data.url.substring(0,29) + "...") : shareData.data.url;
859+
if (sdd.url){
860+
ask = "<p><b>" + SepiaFW.local.g('link_open_url') + "</b></p>";
861+
ask += "<b>URL:</b> ";
862+
ask += (sdd.url.length > 30)? (sdd.url.substring(0,29) + "...") : sdd.url;
863+
}else if (sdd.data && sdd.data.type && (sdd.data.type == "musicSearch" || sdd.data.type == "videoSearch")){
864+
ask = "<p><b>" + SepiaFW.local.g('link_media_search') + "</b></p>";
865+
if (sdd.data.brand) ask += "<p>Link Card Type: " + sdd.data.brand + "</p>";
866+
ask += sdd.data.title;
867+
}else{
868+
ask = "<p><b>" + "Link Card" + "</b></p>";
869+
ask += "<b>Unknown</b>";
862870
}
863871
}else if (shareData.type == SepiaFW.client.SHARE_TYPE_CHANNEL_INVITE){
864872
//Channel Invite
865873
ask = "<p><b>" + SepiaFW.local.g('link_join_channel') + "</b></p>";
866-
ask += "<b>Channel Name:</b> " + shareData.data.name + "<br>";
867-
ask += "<b>Channel Owner:</b> " + shareData.data.owner;
874+
ask += "<b>Channel Name:</b> " + sdd.name + "<br>";
875+
ask += "<b>Channel Owner:</b> " + sdd.owner;
868876
}else if (shareData.type == SepiaFW.client.SHARE_TYPE_ALARM){
869877
//Alarm
870878
ask = "<p><b>" + SepiaFW.local.g('link_create_reminder') + "</b></p>";
871-
ask += "<b>Title:</b> " + shareData.data.title;
879+
ask += "<b>Title:</b> " + sdd.title;
872880
}else{
873881
//Other
874882
ask = "<p>Shared data of type: <b>" + shareData.type.toUpperCase() + "</b></p>";
875883
}
876884
SepiaFW.ui.askForPermissionToExecute(ask, function(){
877885
//ALARM
878-
if (shareData.type == SepiaFW.client.SHARE_TYPE_ALARM && shareData.data.beginTime){
886+
if (shareData.type == SepiaFW.client.SHARE_TYPE_ALARM && sdd.beginTime){
879887
var options = {}; //things like skipTTS etc. (see sendCommand function)
880888
var dataset = {
881889
info: "direct_cmd",
882-
cmd: "timer;;alarm_name=" + (shareData.data.title || "Shared Alarm")
890+
cmd: "timer;;alarm_name=" + (sdd.title || "Shared Alarm")
883891
+ ";;alarm_type=" + "<alarmClock>"
884-
+ ";;time=" + "<unix>" + shareData.data.beginTime
885-
+ ";;clock=" + "<unix>" + shareData.data.beginTime
892+
+ ";;time=" + "<unix>" + sdd.beginTime
893+
+ ";;clock=" + "<unix>" + sdd.beginTime
886894
+ ";;action=<set>",
887895
newReceiver: SepiaFW.assistant.id
888896
};
@@ -900,7 +908,7 @@ function sepiaFW_build_webSocket_client(sepiaSessionId){
900908
var nluResult = {
901909
command: "open_link"
902910
}
903-
var serviceResult = SepiaFW.embedded.services.link(nluInput, nluResult, shareData.data);
911+
var serviceResult = SepiaFW.embedded.services.link(nluInput, nluResult, sdd);
904912
//serviceResult.answer = "";
905913
//serviceResult.answer_clean = "";
906914
var assistantIdOrName = ""; //SepiaFW.assistant.id
@@ -911,7 +919,7 @@ function sepiaFW_build_webSocket_client(sepiaSessionId){
911919
//CHANNEL INVITE
912920
}else if (shareData.type == SepiaFW.client.SHARE_TYPE_CHANNEL_INVITE){
913921
//send request
914-
SepiaFW.client.joinNewChannel(shareData.data, function(res){
922+
SepiaFW.client.joinNewChannel(sdd, function(res){
915923
//additional onSuccess
916924
SepiaFW.ui.showPopup(SepiaFW.local.g('joinedChannel') + ":"
917925
+ "<br><br><b>Name:</b> " + res.channelName

0 commit comments

Comments
 (0)