diff --git a/ts/mains/main_renderer.tsx b/ts/mains/main_renderer.tsx index b9c80b0d2..2781b9bb5 100644 --- a/ts/mains/main_renderer.tsx +++ b/ts/mains/main_renderer.tsx @@ -511,91 +511,3 @@ function onEmpty() { Notifications.enable(); } - -class TextScramble { - private frame: any; - private queue: any; - private readonly el: any; - private readonly chars: any; - private resolve: any; - private frameRequest: any; - - constructor(el: any) { - this.el = el; - this.chars = '0123456789abcdef'; - this.update = this.update.bind(this); - } - - public async setText(newText: string) { - const oldText = this.el.value; - const length = Math.max(oldText.length, newText.length); - // eslint-disable-next-line no-return-assign, no-promise-executor-return - const promise = new Promise(resolve => (this.resolve = resolve)); - this.queue = []; - - for (let i = 0; i < length; i++) { - const from = oldText[i] || ''; - const to = newText[i] || ''; - const startNumber = Math.floor(Math.random() * 40); - const end = startNumber + Math.floor(Math.random() * 40); - this.queue.push({ - from, - to, - start: startNumber, - end, - }); - } - - cancelAnimationFrame(this.frameRequest); - this.frame = 0; - this.update(); - return promise; - } - - public update() { - let output = ''; - let complete = 0; - - for (let i = 0, n = this.queue.length; i < n; i++) { - const { from, to, start: startNumber, end } = this.queue[i]; - let { char } = this.queue[i]; - - if (this.frame >= end) { - complete++; - output += to; - } else if (this.frame >= startNumber) { - if (!char || Math.random() < 0.28) { - char = this.randomChar(); - this.queue[i].char = char; - } - output += char; - } else { - output += from; - } - } - - this.el.value = output; - - if (complete === this.queue.length) { - this.resolve(); - } else { - this.frameRequest = requestAnimationFrame(this.update); - this.frame++; - } - } - - public randomChar() { - return this.chars[Math.floor(Math.random() * this.chars.length)]; - } -} -window.Session = window.Session || {}; - -// TODO[ses-50] remove this since we no longer show the session id in onboarding -window.Session.setNewSessionID = (sessionID: string) => { - const el = document.querySelector('.session-id-editable-textarea'); - const fx = new TextScramble(el); - if (el) { - (el as any).value = sessionID; - } - void fx.setText(sessionID); -};