Skip to content

Commit

Permalink
fix: package update, type declaration fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
muke1908 committed Jul 1, 2023
2 parents 2f42a08 + e817050 commit 3426b13
Show file tree
Hide file tree
Showing 15 changed files with 14,781 additions and 19,203 deletions.
28,606 changes: 12,221 additions & 16,385 deletions client/package-lock.json

Large diffs are not rendered by default.

25 changes: 8 additions & 17 deletions client/src/components/LinkDisplay/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import React, { useRef, useState, useContext } from "react";
import { FiLink, FiCopy, FiExternalLink } from "react-icons/fi";
import styles from "./Style.module.css";
import { ThemeContext } from "../../ThemeContext";
import React, { useRef, useState, useContext } from 'react';
import { FiLink, FiCopy, FiExternalLink } from 'react-icons/fi';
import styles from './Style.module.css';
import { ThemeContext } from '../../ThemeContext';
import { LinkObjType } from '@chat-e2ee/service';

type LinkDisplayProps = {
content: { absoluteLink: string; pin: string } | string;
};

const LinkDisplay = ({ content }: LinkDisplayProps) => {
let chatLink = "";
if (typeof content === "object" && content !== null) {
chatLink = content.absoluteLink;
} else {
chatLink = `${window.location.protocol}//${window.location.host}${content}`;
}
const LinkDisplay: React.FC<{ content: LinkObjType}> = ( { content } ) => {
const chatLink = content.absoluteLink || `${window.location.protocol}//${window.location.host}/${content.hash}`;
const textAreaRef = useRef<HTMLInputElement | null>(null);
const [buttonText, setButtonText] = useState("Copy");
const [darkMode] = useContext(ThemeContext);
Expand All @@ -32,7 +24,7 @@ const LinkDisplay = ({ content }: LinkDisplayProps) => {
<div className={styles.fullWidth}>
<div className={styles.divider} />
<span className={styles.pinDisplayMsg}>
Anyone with the PIN or the Link can join your chat
Anyone with the Link can join your chat
</span>
<div
className={`${styles.copyToClipboardContainer}
Expand Down Expand Up @@ -60,7 +52,6 @@ const LinkDisplay = ({ content }: LinkDisplayProps) => {
</button>
</div>
</div>

<div className={styles.divider} />
<div
className={`${styles.openLink}
Expand Down
6 changes: 3 additions & 3 deletions client/src/pages/chatlink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { ThemeContext } from "../../ThemeContext";
import styles from "./Style.module.css";
import ThemeToggle from "../../components/ThemeToggle/index";

import { createChatInstance } from "@chat-e2ee/service";
import { createChatInstance, LinkObjType } from "@chat-e2ee/service";

const App = () => {
const [chatLink, setChatLink] = useState("");
const [chatLink, setChatLink] = useState<LinkObjType>(null);
const [loading, setLoading] = useState(false);
const [darkMode] = useContext(ThemeContext);

Expand All @@ -20,7 +20,7 @@ const App = () => {
setLoading(true);
try {
const chate2ee = createChatInstance();
const linkResp: string = await chate2ee.getLink();
const linkResp = await chate2ee.getLink();
setChatLink(linkResp);
} catch (error: any) {
console.error(error);
Expand Down
18 changes: 11 additions & 7 deletions client/src/pages/messaging/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useState, useRef, useContext } from "react";
import { useParams, useHistory } from "react-router-dom";

import { createChatInstance, generateUUID, cryptoUtils } from "@chat-e2ee/service";
import { createChatInstance, generateUUID, cryptoUtils, SOCKET_LISTENERS } from "@chat-e2ee/service";

import {
getUserSessionID,
Expand Down Expand Up @@ -172,7 +172,7 @@ const Chat = () => {
useEffect(() => {
// this is update the public key ref
initPublicKey(channelID).then(() => {
chate2ee.on("limit-reached", () => {
chate2ee.on(SOCKET_LISTENERS.LIMIT_REACHED, () => {
setMessages((prevMsg) =>
prevMsg.concat({
image: "",
Expand All @@ -181,19 +181,19 @@ const Chat = () => {
})
);
});
chate2ee.on("delivered", (id: string) => {
chate2ee.on(SOCKET_LISTENERS.DELIVERED, (id: string) => {
setDeliveredID((prev) => [...prev, id]);
});
// an event to notify that the other person is joined.
chate2ee.on("on-alice-join", ({ publicKey }: { publicKey: string | null }) => {
chate2ee.on(SOCKET_LISTENERS.ON_ALICE_JOIN, ({ publicKey }: { publicKey: string | null }) => {
if (publicKey) {
chate2ee.setPublicKey(publicKey);
playNotification();
}
getSetUsers();
});

chate2ee.on("on-alice-disconnect", () => {
chate2ee.on(SOCKET_LISTENERS.ON_ALICE_DISCONNECT, () => {
console.log("alice disconnected!!");
chate2ee.setPublicKey(null);
playNotification();
Expand All @@ -203,18 +203,22 @@ const Chat = () => {

//handle incoming message
chate2ee.on(
"chat-message",
SOCKET_LISTENERS.CHAT_MESSAGE,
async (msg: {
message: string;
image: string;
sender: string;
id: string;
timestamp: Timestamp;
}) => {
if(!myKeyRef.current?.privateKey) {
throw new Error("Private key not found!");
}

try {
const message = await cryptoUtils.decryptMessage(
msg.message,
myKeyRef.current?.privateKey
myKeyRef.current.privateKey
);
setMessages((prevMsg) =>
prevMsg.concat({
Expand Down
1 change: 0 additions & 1 deletion client/src/types/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
declare module "*.module.css";
declare module '@chat-e2ee/service';
declare module "*.mp3"
declare module "*.png"
5 changes: 3 additions & 2 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"isolatedModules": false,
"noEmit": true,
"jsx": "react"
"jsx": "react",
"strictNullChecks": false
},
"include": [
"src"
Expand Down
Loading

0 comments on commit 3426b13

Please sign in to comment.