aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/Main.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2023-04-23 12:34:38 +0300
committerRblSb <msrblsb@gmail.com>2023-04-23 12:34:38 +0300
commit341ec5ce86d1220060f63d2681b6e8eae11ec488 (patch)
treeaa232347348a0bdc75814bed30e057c8af00d237 /src/client/Main.hx
parentb25ebe9ce888b516c6478be2592052a7916a736f (diff)
Use null coalescing op
Diffstat (limited to 'src/client/Main.hx')
-rw-r--r--src/client/Main.hx23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/client/Main.hx b/src/client/Main.hx
index c8688b4..7b8228e 100644
--- a/src/client/Main.hx
+++ b/src/client/Main.hx
@@ -289,8 +289,8 @@ class Main {
serverMessage(Lang.get("addVideoError"));
return;
}
- if (data.title == null) data.title = Lang.get("rawVideo");
- if (data.url == null) data.url = url;
+ data.title ??= Lang.get("rawVideo");
+ data.url ??= url;
send({
type: AddVideo,
addVideo: {
@@ -330,8 +330,8 @@ class Main {
return;
}
if (title.length > 0) data.title = title;
- if (data.title == null) data.title = "Custom Media";
- if (data.url == null) data.url = iframe;
+ data.title ??= "Custom Media";
+ data.url ??= iframe;
send({
type: AddVideo,
addVideo: {
@@ -480,8 +480,8 @@ class Main {
player.play();
case GetTime:
- if (data.getTime.paused == null) data.getTime.paused = false;
- if (data.getTime.rate == null) data.getTime.rate = 1;
+ data.getTime.paused ??= false;
+ data.getTime.rate ??= 1;
if (player.getPlaybackRate() != data.getTime.rate) {
player.setPlaybackRate(data.getTime.rate);
@@ -746,8 +746,7 @@ class Main {
function onLogin(data:Array<ClientData>, clientName:String):Void {
updateClients(data);
- final newPersonal = clients.getByName(clientName);
- if (newPersonal == null) return;
+ final newPersonal = clients.getByName(clientName) ?? return;
personal = newPersonal;
onUserGroupChanged();
hideGuestLoginPanel();
@@ -880,7 +879,7 @@ class Main {
if (date == null) date = Date.now().toString();
else date = getLocalDateFromUtc(date);
final time = date.split(" ")[1];
- tstamp.textContent = time == null ? date : time;
+ tstamp.textContent = time ?? date;
tstamp.title = date;
final nameDiv = document.createElement("strong");
@@ -932,10 +931,8 @@ class Main {
function onChatVideoLoaded(e:Event):Void {
final el:VideoElement = cast e.target;
- if (emoteMaxSize == null) {
- emoteMaxSize = Std.parseInt(window.getComputedStyle(el)
- .getPropertyValue("max-width"));
- }
+ emoteMaxSize ??= Std.parseInt(window.getComputedStyle(el)
+ .getPropertyValue("max-width"));
// fixes default video tag size in chat when tab unloads videos in background
// (some browsers optimization i guess)
final max = emoteMaxSize;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage