@@ -177,6 +166,15 @@ class SessionList: Reactor.Component {
this.$(#forget-password).style.set{
display: handler.peer_has_password(id) ? "block" : "none",
};
+ if (!this.type || this.type == "fav") {
+ var in_fav = handler.get_fav().indexOf(id) >= 0;
+ this.$(#add-fav).style.set{
+ display: in_fav ? "none" : "block",
+ };
+ this.$(#remove-fav).style.set{
+ display: in_fav ? "block" : "none",
+ };
+ }
// https://sciter.com/forums/topic/replacecustomize-context-menu/
var menu = this.$(menu#remote-context);
menu.attributes["remote-id"] = id;
@@ -201,6 +199,20 @@ class SessionList: Reactor.Component {
handler.create_shortcut(id);
} else if (action == "rdp") {
createNewConnect(id, "rdp");
+ } else if (action == "add-fav") {
+ var favs = handler.get_fav();
+ if (favs.indexOf(id) < 0) {
+ favs = [id].concat(favs);
+ handler.store_fav(favs);
+ }
+ app.multipleSessions.update();
+ app.update();
+ } else if (action == "remove-fav") {
+ var favs = handler.get_fav();
+ var i = favs.indexOf(id);
+ favs.splice(i, 1);
+ handler.store_fav(favs);
+ app.multipleSessions.update();
} else if (action == "tunnel") {
createNewConnect(id, "port-forward");
} else if (action == "rename") {
@@ -219,3 +231,51 @@ class SessionList: Reactor.Component {
}
}
}
+
+function getSessionsType() {
+ return handler.get_local_option("show-sessions-type");
+}
+
+class Favorites: Reactor.Component {
+ function render() {
+ var sessions = handler.get_fav().map(function(f) {
+ return handler.get_peer(f);
+ });
+ return
;
+ }
+}
+
+class MultipleSessions: Reactor.Component {
+ function render() {
+ var type = getSessionsType();
+ return
+
+
+ {translate('Recent Sessions')}
+ {translate('Favorites')}
+
+ {!this.hidden &&
}
+ {!this.hidden &&
}
+
+ {!this.hidden &&
+ ((type == "fav" &&
) ||
+
)}
+
;
+ }
+
+ function stupidUpdate() {
+ /* hidden is workaround of stupid sciter bug */
+ this.hidden = true;
+ this.update();
+ var me = this;
+ self.timer(60ms, function() {
+ me.hidden = false;
+ me.update();
+ });
+ }
+
+ event click $(div#sessions-type span.inactive) (_, el) {
+ handler.set_option('show-sessions-type', el.id || "");
+ this.stupidUpdate();
+ }
+}
\ No newline at end of file
diff --git a/src/ui/index.tis b/src/ui/index.tis
index f764ccc81..6680093ac 100644
--- a/src/ui/index.tis
+++ b/src/ui/index.tis
@@ -50,27 +50,6 @@ class ConnectStatus: Reactor.Component {
}
}
-class RecentSessions: Reactor.Component {
- function render() {
- var sessions = handler.get_recent_sessions();
- if (sessions.length == 0) return
;
- return
-
-
- {translate("Recent Sessions")}
-
- {!app.hidden &&
}
- {!app.hidden &&
}
-
- {!app.hidden &&
}
-
;
- }
-
- function filter(v) {
- this.sessionList.filter(v);
- }
-}
-
function createNewConnect(id, type) {
id = id.replace(/\s/g, "");
app.remote_id.value = formatId(id);
@@ -301,7 +280,7 @@ class App: Reactor.Component