From 49cdb8fda6791d92ae78b0e216e31232202c4e88 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Wed, 6 Nov 2024 11:58:01 -0600 Subject: [PATCH] Various fixes --- src/webpage/channel.ts | 11 +++++++++++ src/webpage/contextmenu.ts | 28 +++++++++++++++++++++++++++- src/webpage/infiniteScroller.ts | 4 ++++ src/webpage/localuser.ts | 7 ++++--- src/webpage/login.ts | 3 ++- src/webpage/manifest.json | 7 ++++--- src/webpage/message.ts | 16 +++++++++++++++- 7 files changed, 67 insertions(+), 9 deletions(-) diff --git a/src/webpage/channel.ts b/src/webpage/channel.ts index f1451ce..2d71e98 100644 --- a/src/webpage/channel.ts +++ b/src/webpage/channel.ts @@ -579,6 +579,17 @@ class Channel extends SnowFlake{ } return div; } + async moveForDrag(x:number){ + const mainarea=document.getElementById("mainarea"); + if(!mainarea) return; + if(x===-1){ + mainarea.style.removeProperty("left"); + mainarea.style.removeProperty("transition"); + return; + } + mainarea.style.left=x+"px"; + mainarea.style.transition="left 0s" + } async setUpVoice(){ if(!this.voice) return; this.voice.onMemberChange=async (memb,joined)=>{ diff --git a/src/webpage/contextmenu.ts b/src/webpage/contextmenu.ts index a5559db..8b37ab2 100644 --- a/src/webpage/contextmenu.ts +++ b/src/webpage/contextmenu.ts @@ -84,7 +84,7 @@ class Contextmenu{ Contextmenu.currentmenu = div; return this.div; } - bindContextmenu(obj: HTMLElement, addinfo: x, other: y){ + bindContextmenu(obj: HTMLElement, addinfo: x, other: y,touchDrag:(x:number,y:number)=>unknown=()=>{},touchEnd:(x:number,y:number)=>unknown=()=>{}){ const func = (event: MouseEvent)=>{ event.preventDefault(); event.stopImmediatePropagation(); @@ -92,13 +92,39 @@ class Contextmenu{ }; obj.addEventListener("contextmenu", func); if(iOS){ + let hold:NodeJS.Timeout|undefined; + let x!:number; + let y!:number; obj.addEventListener("touchstart",(event: TouchEvent)=>{ + x=event.touches[0].pageX; + y=event.touches[0].pageY; if(event.touches.length > 1){ event.preventDefault(); event.stopImmediatePropagation(); this.makemenu(event.touches[0].clientX, event.touches[0].clientY, addinfo, other); + }else{ + // + event.stopImmediatePropagation(); + hold=setTimeout(()=>{ + if(lastx**2+lasty**2>10**2) return; + this.makemenu(event.touches[0].clientX, event.touches[0].clientY, addinfo, other); + console.log(obj); + },500) } },{passive: false}); + let lastx=0; + let lasty=0; + obj.addEventListener("touchend",()=>{ + if(hold){ + clearTimeout(hold); + } + touchEnd(lastx,lasty); + }); + obj.addEventListener("touchmove",(event)=>{ + lastx=event.touches[0].pageX-x; + lasty=event.touches[0].pageY-y; + touchDrag(lastx,lasty); + }); } return func; } diff --git a/src/webpage/infiniteScroller.ts b/src/webpage/infiniteScroller.ts index ee7a4b0..55202d8 100644 --- a/src/webpage/infiniteScroller.ts +++ b/src/webpage/infiniteScroller.ts @@ -147,6 +147,7 @@ offset: number if(nextid){ const html = await this.getHTMLFromID(nextid); + if(!html){ this.destroyFromID(nextid); return false; @@ -155,6 +156,7 @@ offset: number fragment.prepend(html); this.HTMLElements.unshift([html, nextid]); this.scrollTop += this.averageheight; + } } if(this.scrollTop > this.maxDist){ @@ -162,7 +164,9 @@ offset: number if(html){ again = true; await this.destroyFromID(html[1]); + this.scrollTop -= this.averageheight; + } } if(again){ diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index 9947d75..0230945 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -1231,10 +1231,11 @@ class Localuser{ } { - const userinfos = getBulkInfo(); + let userinfos = getBulkInfo(); tas.addColorInput( I18n.getTranslation("localuser.accentColor"), _=>{ + userinfos = getBulkInfo(); userinfos.accent_color = _; localStorage.setItem("userinfos", JSON.stringify(userinfos)); document.documentElement.style.setProperty( @@ -1347,11 +1348,11 @@ class Localuser{ method: "PATCH", } ); - form.addTextInput(I18n.getTranslation("lcoaluser.newDiscriminator"), "discriminator"); + form.addTextInput(I18n.getTranslation("localuser.newDiscriminator"), "discriminator"); }); security.addButtonInput("", I18n.getTranslation("localuser.changeEmail"), ()=>{ const form = security.addSubForm( - I18n.getTranslation("lcoaluser.changeEmail"), + I18n.getTranslation("localuser.changeEmail"), _=>{ security.returnFromSub(); }, diff --git a/src/webpage/login.ts b/src/webpage/login.ts index 719f19e..7a604ac 100644 --- a/src/webpage/login.ts +++ b/src/webpage/login.ts @@ -89,7 +89,7 @@ function trimswitcher(){ } function getBulkInfo(){ - return JSON.parse(localStorage.getItem("userinfos")!); + return JSON.parse(localStorage.getItem("userinfos") as string); } function setDefaults(){ let userinfos = getBulkInfo(); @@ -126,6 +126,7 @@ function setDefaults(){ }; } if(userinfos.preferences && userinfos.preferences.notisound === undefined){ + console.warn("uhoh") userinfos.preferences.notisound = "three"; } localStorage.setItem("userinfos", JSON.stringify(userinfos)); diff --git a/src/webpage/manifest.json b/src/webpage/manifest.json index dca0dc2..f78e7cd 100644 --- a/src/webpage/manifest.json +++ b/src/webpage/manifest.json @@ -2,11 +2,12 @@ "name": "Jank Client", "icons": [ { - "src": "/logo.svg", + "src": "/logo.webp", "sizes": "512x512" } ], "start_url": "/channels/@me", "display": "standalone", - "theme_color": "#05050a" -} \ No newline at end of file + "theme_color": "#05050a", + "offline_enabled": true +} diff --git a/src/webpage/message.ts b/src/webpage/message.ts index 574a106..e0fb044 100644 --- a/src/webpage/message.ts +++ b/src/webpage/message.ts @@ -208,7 +208,21 @@ class Message extends SnowFlake{ return this.owner.info; } messageevents(obj: HTMLDivElement){ - Message.contextmenu.bindContextmenu(obj, this, undefined); + Message.contextmenu.bindContextmenu(obj, this, undefined,(x)=>{ + //console.log(x,y); + this.channel.moveForDrag(Math.max(x,0)); + + },(x,y)=>{ + console.log(x,y); + this.channel.moveForDrag(-1); + if(x>60){ + console.log("In here?") + const toggle = document.getElementById("maintoggle") as HTMLInputElement; + toggle.checked = false; + console.log(toggle); + } + + },); this.div = obj; obj.classList.add("messagediv"); }