Some updates related to the native client

canary
WolverinDEV 2019-04-25 20:22:13 +02:00
parent 9a4ec00b12
commit 3a255b2316
7 changed files with 38 additions and 15 deletions

View File

@ -3,4 +3,6 @@
declare namespace forum {
export function register_callback(callback: () => any);
export function open();
export function logout();
export function sync_main();
}

View File

@ -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;

View File

@ -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);

View File

@ -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",

View File

@ -23,7 +23,6 @@ interface Window {
open_connected_question: () => Promise<boolean>;
}
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 () => {

View File

@ -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();

View File

@ -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());