From 1ad608ff728fd9c1451f39ed24e4c167c145a6db Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 21 Dec 2019 16:46:56 +0100 Subject: [PATCH] Improved the connect modal and updated the change log Signed-off-by: WolverinDEV --- ChangeLog.md | 3 +++ shared/js/ConnectionHandler.ts | 1 + shared/js/settings.ts | 3 ++- shared/js/ui/modal/ModalConnect.ts | 34 ++++++++++++++++------------- shared/js/ui/modal/ModalSettings.ts | 3 +++ 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index f7627491..692f4d43 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,9 @@ - Added Headings to the chat - Added `[hr]` or `___` to the chat - Added support for tables within the chat + - Fixed "undefined" history when pressing `arrowup` within the chat box + - Correctly logging ban messages within the server log + - Capturing last used profile for connect * **20.12.19** - Fixing chat URL escaping diff --git a/shared/js/ConnectionHandler.ts b/shared/js/ConnectionHandler.ts index ad43a171..db8e6a04 100644 --- a/shared/js/ConnectionHandler.ts +++ b/shared/js/ConnectionHandler.ts @@ -292,6 +292,7 @@ class ConnectionHandler { this.channelTree.toggle_server_queries(this.client_status.queries_visible); this.sync_status_with_server(); + this.channelTree.server.updateProperties(); /* No need to update the voice stuff because as soon we see ourself we're doing it this.update_voice_status(); diff --git a/shared/js/settings.ts b/shared/js/settings.ts index b8405d24..da06ba97 100644 --- a/shared/js/settings.ts +++ b/shared/js/settings.ts @@ -197,7 +197,8 @@ class Settings extends StaticSettings { key: 'connect_address' }; static readonly KEY_CONNECT_PROFILE: SettingsKey = { - key: 'connect_profile' + key: 'connect_profile', + default_value: 'default' }; static readonly KEY_CONNECT_USERNAME: SettingsKey = { key: 'connect_username' diff --git a/shared/js/ui/modal/ModalConnect.ts b/shared/js/ui/modal/ModalConnect.ts index 46382f90..39710881 100644 --- a/shared/js/ui/modal/ModalConnect.ts +++ b/shared/js/ui/modal/ModalConnect.ts @@ -118,9 +118,9 @@ namespace Modals { modal.htmlTag.find(".modal-body").addClass("modal-connect"); - const container_last_servers = modal.htmlTag.find(".container-last-servers"); /* server list toggle */ { + const container_last_servers = modal.htmlTag.find(".container-last-servers"); const button = modal.htmlTag.find(".button-toggle-last-servers"); const set_show = shown => { container_last_servers.toggleClass('shown', shown); @@ -134,8 +134,8 @@ namespace Modals { } const apply = (header, body, footer) => { - const container = modal.htmlTag.find(".container-last-servers .table .body"); - const container_empty = container.find(".body-empty"); + const container_last_server_body = modal.htmlTag.find(".container-last-servers .table .body"); + const container_empty = container_last_server_body.find(".body-empty"); let current_connect_data: connection_log.ConnectionEntry; const button_connect = footer.find(".button-connect"); @@ -150,10 +150,9 @@ namespace Modals { let updateFields = (reset_current_data: boolean) => { if(reset_current_data) { current_connect_data = undefined; - container.find(".selected").removeClass("selected"); + container_last_server_body.find(".selected").removeClass("selected"); } - console.log("Updating"); let address = input_address.val().toString(); settings.changeGlobal(Settings.KEY_CONNECT_ADDRESS, address); let flag_address = !!address.match(Regex.IP_V4) || !!address.match(Regex.IP_V6) || !!address.match(Regex.DOMAIN); @@ -180,7 +179,6 @@ namespace Modals { if(event.keyCode == KeyCode.KEY_ENTER && !event.shiftKey) button_connect.trigger('click'); }); - button_manage.on('click', event => { const modal = Modals.spawnSettingsModal("identity-profiles"); modal.close_listener.push(() => { @@ -189,7 +187,7 @@ namespace Modals { return true; }); - const last_nickname = settings.static_global(Settings.KEY_CONNECT_USERNAME, undefined); + /* Connect Profiles */ { for(const profile of profiles.profiles()) { input_profile.append( @@ -198,18 +196,25 @@ namespace Modals { } input_profile.on('change', event => { - selected_profile = profiles.find_profile(input_profile.val() as string); + selected_profile = profiles.find_profile(input_profile.val() as string) || profiles.default_profile(); { settings.changeGlobal(Settings.KEY_CONNECT_USERNAME, undefined); input_nickname .attr('placeholder', selected_profile.connect_username() || "Another TeaSpeak user") .val(""); } + + settings.changeGlobal(Settings.KEY_CONNECT_PROFILE, selected_profile.id); input_profile.toggleClass("is-invalid", !selected_profile || !selected_profile.valid()); updateFields(true); }); - input_profile.val(connect_profile && connect_profile.enforce ? connect_profile.profile.id : connect_profile && connect_profile.profile ? connect_profile.profile.id : 'default').trigger('change'); + input_profile.val(connect_profile && connect_profile.profile ? + connect_profile.profile.id : + settings.static_global(Settings.KEY_CONNECT_PROFILE, "default") + ).trigger('change'); } + + const last_nickname = settings.static_global(Settings.KEY_CONNECT_USERNAME, undefined); if(last_nickname) /* restore */ settings.changeGlobal(Settings.KEY_CONNECT_USERNAME, last_nickname); @@ -258,7 +263,7 @@ namespace Modals { }); - /* server list show */ + /* connect history show */ { for(const entry of connection_log.history().slice(0, 10)) { $.spawn("div").addClass("row").append( @@ -270,7 +275,7 @@ namespace Modals { row.detach(); }); connection_log.delete_entry(entry.address); - container_empty.toggle(container.children().length > 1); + container_empty.toggle(container_last_server_body.children().length > 1); }) ).append( $.spawn("div").addClass("column name").append([ @@ -296,18 +301,17 @@ namespace Modals { event.preventDefault(); current_connect_data = entry; - container.find(".selected").removeClass("selected"); + container_last_server_body.find(".selected").removeClass("selected"); $(event.target).parent('.row').addClass('selected'); input_address.val(entry.address.hostname + (entry.address.port != 9987 ? (":" + entry.address.port) : "")); - input_password.val(entry.password_hash ? "WolverinDEV Yeahr!" : "").trigger('change'); + input_password.val(entry.flag_password && entry.password_hash ? "WolverinDEV Yeahr!" : "").trigger('change'); }).on('dblclick', event => { current_connect_data = entry; button_connect.trigger('click'); - }).appendTo(container); + }).appendTo(container_last_server_body); container_empty.toggle(false); } - } }; apply(modal.htmlTag, modal.htmlTag, modal.htmlTag); diff --git a/shared/js/ui/modal/ModalSettings.ts b/shared/js/ui/modal/ModalSettings.ts index 06251eac..dc0d1cda 100644 --- a/shared/js/ui/modal/ModalSettings.ts +++ b/shared/js/ui/modal/ModalSettings.ts @@ -1230,6 +1230,9 @@ namespace Modals { profiles.set_default_profile(selected_profile.identity); profiles.mark_need_save(); update_profiles(selected_profile.identity.id); + + /* set the connect profile to the just set once */ + settings.changeGlobal(Settings.KEY_CONNECT_PROFILE, "default"); }); selected_profile_changed.push(() => {