diff --git a/client/declarations/exports.d.ts b/client/declarations/exports.d.ts index 6ac56514..58d33e07 100644 --- a/client/declarations/exports.d.ts +++ b/client/declarations/exports.d.ts @@ -3,4 +3,6 @@ declare namespace forum { export function register_callback(callback: () => any); export function open(); + export function logout(); + export function sync_main(); } diff --git a/shared/js/ConnectionHandler.ts b/shared/js/ConnectionHandler.ts index a07fd5cc..712b3eca 100644 --- a/shared/js/ConnectionHandler.ts +++ b/shared/js/ConnectionHandler.ts @@ -410,7 +410,7 @@ class ConnectionHandler { case DisconnectReason.HANDSHAKE_TEAMSPEAK_REQUIRED: createErrorModal( tr("Target server is a TeamSpeak server"), - MessageHelper.formatMessage(tr("The target server is a TeamSpeak 3 server!{:br:}Only TeamSpeak 3 based identities are able to connect.{:br}Please select another profile or change the identify type.")) + MessageHelper.formatMessage(tr("The target server is a TeamSpeak 3 server!{:br:}Only TeamSpeak 3 based identities are able to connect.{:br:}Please select another profile or change the identify type.")) ).open(); this.sound.play(Sound.CONNECTION_DISCONNECTED); auto_reconnect = false; diff --git a/shared/js/FileManager.ts b/shared/js/FileManager.ts index 116fbe81..15dea6c5 100644 --- a/shared/js/FileManager.ts +++ b/shared/js/FileManager.ts @@ -145,7 +145,7 @@ class FileManager extends connection.AbstractCommandHandler { private pending_download_requests: transfer.DownloadKey[] = []; private pending_upload_requests: transfer.UploadKey[] = []; - private transfer_counter : number = 0; + private transfer_counter : number = 1; constructor(client: ConnectionHandler) { super(client.serverConnection); diff --git a/shared/js/log.ts b/shared/js/log.ts index 7b588eee..1ca4c3a0 100644 --- a/shared/js/log.ts +++ b/shared/js/log.ts @@ -53,7 +53,7 @@ namespace log { NATIVE, PREFIX } - const group_mode: GroupMode = GroupMode.NATIVE; + const group_mode: GroupMode = GroupMode.PREFIX; loader.register_task(loader.Stage.LOADED, { name: "log enabled initialisation", diff --git a/shared/js/main.ts b/shared/js/main.ts index 2b5f9ded..9211334a 100644 --- a/shared/js/main.ts +++ b/shared/js/main.ts @@ -23,7 +23,6 @@ interface Window { open_connected_question: () => Promise; } - function setup_close() { window.onbeforeunload = event => { if(profiles.requires_save()) @@ -111,15 +110,6 @@ async function initialize_app() { displayCriticalError(message); }; - try { - if(!setup_jsrender()) - throw "invalid load"; - } catch (error) { - display_load_error(tr("Failed to setup jsrender")); - console.error(tr("Failed to load jsrender! %o"), error); - return; - } - try { //Initialize main template const main = $("#tmpl_main").renderTag().dividerfy(); @@ -413,6 +403,21 @@ const task_certificate_callback: loader.Task = { priority: 10 }; +loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, { + name: "jrendere initialize", + function: async () => { + try { + if(!setup_jsrender()) + throw "invalid load"; + } catch (error) { + displayCriticalError(tr("Failed to setup jsrender")); + console.error(tr("Failed to load jsrender! %o"), error); + return; + } + }, + priority: 100 +}) + loader.register_task(loader.Stage.LOADED, { name: "app starter", function: async () => { diff --git a/shared/js/profiles/ConnectionProfile.ts b/shared/js/profiles/ConnectionProfile.ts index 03a86e3b..fd666c2d 100644 --- a/shared/js/profiles/ConnectionProfile.ts +++ b/shared/js/profiles/ConnectionProfile.ts @@ -107,7 +107,16 @@ namespace profiles { available_profiles = []; const profiles_json = localStorage.getItem("profiles"); - let profiles_data: ProfilesData = profiles_json ? JSON.parse(profiles_json) : {version: 0} as any; + let profiles_data: ProfilesData = (() => { + try { + return profiles_json ? JSON.parse(profiles_json) : {version: 0} as any; + } catch(error) { + debugger; + console.error(tr("Invalid profile json! Resetting profiles :( (%o)"), profiles_json); + createErrorModal(tr("Profile data invalid"), MessageHelper.formatMessage(tr("The profile data is invalid.{:br:}This might cause data loss."))).open(); + return {version: 0}; + } + })(); if(profiles_data.version === 0) { profiles_data = { @@ -153,6 +162,9 @@ namespace profiles { profile.default_password = ""; profile.default_username = "Another TeaSpeak user"; profile.profile_name = "TeaSpeak Forum profile"; + + profile.set_identity(identities.IdentitifyType.TEAFORO, identities.static_forum_identity()); + profile.selected_identity_type = identities.IdentitifyType[identities.IdentitifyType.TEAFORO]; } save(); diff --git a/shared/js/proto.ts b/shared/js/proto.ts index 41107d66..82044349 100644 --- a/shared/js/proto.ts +++ b/shared/js/proto.ts @@ -118,12 +118,16 @@ if(typeof ($) !== "undefined") { } } if(!$.fn.renderTag) { - $.fn.renderTag = function (values?: any) : JQuery { + $.fn.renderTag = function (this: JQuery, values?: any) : JQuery { let result; if(this.render) { result = $(this.render(values)); } else { const template = window.jsrender.render[this.attr("id")]; + if(!template) { + console.error("Tried to render template %o, but template is not available!", this.attr("id")); + throw "missing template " + this.attr("id"); + } /* result = window.jsrender.templates("tmpl_permission_entry", $("#tmpl_permission_entry").html()); result = window.jsrender.templates("xxx", this.html());