some client fixes

This commit is contained in:
WolverinDEV 2019-01-02 11:38:48 +01:00
parent 615c39360a
commit a04b6a2a21
4 changed files with 31 additions and 6 deletions

View file

@ -73,7 +73,7 @@
echo ("type\thash\tpath\tname\n"); echo ("type\thash\tpath\tname\n");
foreach (list_dir($UI_RAW_BASE_PATH) as $file) { foreach (list_dir($UI_RAW_BASE_PATH) as $file) {
$type_idx = strrpos($file, "."); $type_idx = strrpos($file, ".");
$type = substr($file, $type_idx + 1); $type = $type_idx > 0 ? substr($file, $type_idx + 1) : "";
if($type == "php") $type = "html"; if($type == "php") $type = "html";
$name_idx = strrpos($file, "/"); $name_idx = strrpos($file, "/");
@ -81,9 +81,10 @@
$path = $name_idx > 0 ? substr($file, 0, $name_idx) : "."; $path = $name_idx > 0 ? substr($file, 0, $name_idx) : ".";
$name_idx = strrpos($name, "."); $name_idx = strrpos($name, ".");
$name = substr($name, 0, $name_idx); if($name_idx > 0)
$name = substr($name, 0, $name_idx);
echo $type . "\t" . sha1_file($UI_RAW_BASE_PATH . $file) . "\t" . $path . "\t" . $name . "." . $type . "\n"; echo $type . "\t" . sha1_file($UI_RAW_BASE_PATH . $file) . "\t" . $path . "\t" . $name . (strlen($type) > 0 ? "." . $type : "") . "\n";
} }
die; die;
} else if($_GET["type"] === "file") { } else if($_GET["type"] === "file") {

View file

@ -1,9 +1,11 @@
import TeaForumIdentity = profiles.identities.TeaForumIdentity;
const ipc = require("electron").ipcRenderer; const ipc = require("electron").ipcRenderer;
let callback_listener: (() => any)[] = []; let callback_listener: (() => any)[] = [];
ipc.on('teaforo-update', (event, data: forum.UserData) => { ipc.on('teaforo-update', (event, data: forum.UserData) => {
console.log("Got data update: %o", data); console.log("Got data update: %o", data);
forumIdentity = data ? new TeaForumIdentity(data.application_data, data.application_data_sign) : undefined; profiles.identities.set_static_identity(data ? new TeaForumIdentity(data.application_data, data.application_data_sign) : undefined);
try { try {
for(let listener of callback_listener) for(let listener of callback_listener)
setImmediate(listener); setImmediate(listener);

View file

@ -56,9 +56,9 @@ namespace loader {
}); });
return; return;
} }
const task_array = tasks[stage] || (tasks[stage] = []); const task_array = tasks[stage] || [];
task_array.push(task); task_array.push(task);
task_array.sort((a, b) => a.priority < b.priority ? 1 : 0); tasks[stage] = task_array.sort((a, b) => a.priority > b.priority ? 1 : 0);
} }
export async function execute() { export async function execute() {
@ -78,6 +78,7 @@ namespace loader {
const promises: Promise<void>[] = []; const promises: Promise<void>[] = [];
for(const task of current_tasks) { for(const task of current_tasks) {
try { try {
console.debug("Executing loader %s (%d)", task.name, task.priority);
promises.push(task.function().catch(error => { promises.push(task.function().catch(error => {
errors.push({ errors.push({
task: task, task: task,
@ -560,6 +561,23 @@ loader.register_task(loader.Stage.INITIALIZING, {
priority: 50 priority: 50
}); });
/* TeaClient */
if(window.require) {
const path = require("path");
const remote = require('electron').remote;
module.paths.push(path.join(remote.app.getAppPath(), "/modules"));
module.paths.push(path.join(path.dirname(remote.getGlobal("browser-root")), "js"));
const connector = require("renderer");
console.log(connector);
loader.register_task(loader.Stage.INITIALIZING, {
name: "teaclient initialize",
function: connector.initialize,
priority: 40
});
}
loader.register_task(loader.Stage.INITIALIZING, { loader.register_task(loader.Stage.INITIALIZING, {
name: "webassembly tester", name: "webassembly tester",
function: loader_webassembly.test_webassembly, function: loader_webassembly.test_webassembly,

View file

@ -87,6 +87,10 @@ namespace profiles.identities {
let static_identity: TeaForumIdentity; let static_identity: TeaForumIdentity;
export function set_static_identity(identity: TeaForumIdentity) {
static_identity = identity;
}
export function setup_forum() { export function setup_forum() {
const user_data = settings.static("forum_user_data") as string; const user_data = settings.static("forum_user_data") as string;
const user_sign = settings.static("forum_user_sign") as string; const user_sign = settings.static("forum_user_sign") as string;