summary refs log tree commit diff
path: root/screen
diff options
context:
space:
mode:
authorWlodekM <[email protected]>2025-01-24 17:38:33 +0200
committerWlodekM <[email protected]>2025-01-24 18:03:39 +0200
commit2d75c97ed1783331d8e12cd4f6456e88b80c73f6 (patch)
tree6271da5dc479d9f8cee8f4459194d55acb6c41a5 /screen
parent5deacee61b572d7a83225073567b4758d1854adf (diff)
working maelink client
Diffstat (limited to 'screen')
-rw-r--r--screen/home.ts14
-rw-r--r--screen/login.ts13
2 files changed, 14 insertions, 13 deletions
diff --git a/screen/home.ts b/screen/home.ts
index 0be3ef9..c6f6c19 100644
--- a/screen/home.ts
+++ b/screen/home.ts
@@ -1,14 +1,14 @@
 import { ElemType } from "../screenbuilder.ts";
 import { Screen } from "../screen.ts";
-import type { Input, Element, Text } from "../elements.ts";
-import * as client from "../client.ts"
+import type { Input, Text } from "../elements.ts";
+import process from "node:process";
 
 export default {
     elements: [
         {
             type: ElemType.TextElem,
             id: 'home',
-            data: ["Loading home posts...\n", function (this: Text, text: string) {
+            data: ["Loading home posts...\n", function (this: Text) {
                 const msgInput: Input = this.screen.elements.get("msg-input") as Input;
                 const inputValueHeight = msgInput.value.split("\n").length + 1;
                 const termHeight = process.stdout.rows;
@@ -36,9 +36,9 @@ export default {
         {
             type: ElemType.ButtonElem,
             id: 'done-btn',
-            data: ["Send", async function (this: Screen) {
+            data: ["Send", function (this: Screen) {
                 const msgInput: Input = this.elements.get('msg-input') as Input
-                client.sendHome(msgInput.value);
+                this.client.sendHome(msgInput.value);
                 msgInput.value = ""
                 this.render()
             }]
@@ -47,7 +47,7 @@ export default {
     focus: "msg-input",
     name: 'home',
     onload (screen: Screen) {
-        client.setScreen(screen)
-        client.loadHome(screen)
+        screen.client.setScreen(screen)
+        screen.client.loadHome(screen)
     }
 }
\ No newline at end of file
diff --git a/screen/login.ts b/screen/login.ts
index bc39655..57121bb 100644
--- a/screen/login.ts
+++ b/screen/login.ts
@@ -1,8 +1,8 @@
 import { ElemType } from "../screenbuilder.ts";
 import { Screen } from "../screen.ts";
-import * as client from "../client.ts"
 import { build } from "../screenbuilder.ts";
 import HomeScreen from "./home.ts";
+import { Input } from "../elements.ts";
 
 export default {
     elements: [
@@ -38,15 +38,16 @@ export default {
             type: ElemType.ButtonElem,
             id: 'done-btn',
             data: ["Done", async function (this: Screen) {
-                client.setScreen(this)
+                this.client.setScreen(this)
                 this.off()
                 this.logs.push(`clicked button`)
                 console.clear()
                 console.log("logging in...")
-                //@ts-ignore
-                await client.login(this.elements.get("username-input").value, this.elements.get("password-input").value)
-                build(HomeScreen);
-                client
+                const usernameInput = this.elements.get("username-input") as Input;
+                const passwordInput = this.elements.get("password-input") as Input;
+                await this.client.login(usernameInput.value, passwordInput.value)
+                build(HomeScreen, this.client);
+                this.client
             }]
         }
     ],