aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/Main.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2025-01-26 23:22:33 +0300
committerRblSb <msrblsb@gmail.com>2025-01-28 15:46:30 +0300
commit0592564264fff57ccfd9677957196951f9f1c6cf (patch)
treec360c2e5d45d9ac8706f836b0466b88221e1f10d /src/client/Main.hx
parentc7518e58788c17ad2ca8340ab5c7633489aa9518 (diff)
Video upload feature
And you can play video as soon as upload starts! This is pretty useful for thicc ones. Video will be keeped in cache and will comply cache size limit. I'm also implemented system storage check to change cache limit if it's lower than config value, so upload will be blocked if there is lower than 10MiB available on disk.
Diffstat (limited to 'src/client/Main.hx')
-rw-r--r--src/client/Main.hx45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/client/Main.hx b/src/client/Main.hx
index 6ec8727..61b3c3a 100644
--- a/src/client/Main.hx
+++ b/src/client/Main.hx
@@ -25,8 +25,6 @@ import js.html.URL;
import js.html.VideoElement;
import js.html.WebSocket;
-using ClientTools;
-
class Main {
public static var instance(default, null):Main;
static inline var SETTINGS_VERSION = 5;
@@ -457,7 +455,7 @@ class Main {
final t = t.charAt(0).toLowerCase() + t.substr(1);
trace('Event: ${data.type}', Reflect.field(data, t));
}
- JsApi.fireOnceEvent(data);
+ JsApi.fireEvents(data);
switch (data.type) {
case Connected:
onConnected(data);
@@ -509,6 +507,26 @@ class Main {
}
serverMessage(text);
+ case Progress:
+ final data = data.progress;
+ final text = switch data.type {
+ case Caching:
+ final caching = Lang.get("caching");
+ final name = data.data;
+ '$caching $name';
+ case Downloading: Lang.get("downloading");
+ case Uploading: Lang.get("uploading");
+ }
+ final percent = (data.ratio * 100).toFixed(1);
+ var text = '$text...';
+ if (percent > 0) text += ' $percent%';
+ showProgressInfo(text);
+ if (data.ratio == 1) {
+ Timer.delay(() -> {
+ hideDynamicChin();
+ }, 500);
+ }
+
case AddVideo:
player.addVideoItem(data.addVideo.item, data.addVideo.atEnd);
if (player.itemsLength() == 1) player.setVideo(0);
@@ -934,7 +952,7 @@ class Main {
return msgBuf.lastElementChild?.className.startsWith("server-msg");
}
- public function serverMessage(text:String, isText = true, withTimestamp = true):Void {
+ public function serverMessage(text:String, isText = true, withTimestamp = true):Element {
final div = document.createDivElement();
final time = Date.now().toString().split(" ")[1];
div.className = "server-whisper";
@@ -947,6 +965,7 @@ class Main {
else textDiv.innerHTML = text;
addMessageDiv(div);
scrollChatToEnd();
+ return div;
}
public function serverHtmlMessage(el:Element):Void {
@@ -1071,6 +1090,18 @@ class Main {
}, {once: true});
}
+ public function showProgressInfo(text:String):Void {
+ final chin = ge("#dynamic-chin");
+ var div = chin.querySelector("#progress-info");
+ if (div == null) {
+ div = document.createDivElement();
+ div.id = "progress-info";
+ chin.prepend(div);
+ }
+ div.textContent = text;
+ showDynamicChin();
+ }
+
public function showServerUnpause():Void {
if (showingServerPause) return;
showingServerPause = true;
@@ -1096,6 +1127,12 @@ class Main {
JsApi.once(SetLeader, event -> removeLeader());
}
+ showDynamicChin();
+ }
+
+ function showDynamicChin():Void {
+ final chin = ge("#dynamic-chin");
+ if (chin.style.display == "") return;
chin.style.display = "";
chin.style.transition = "none";
chin.classList.remove("collapsed");
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage