Skip to content

Commit

Permalink
fix: type/service (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
muke1908 authored Jul 1, 2023
1 parent 4bf9a95 commit 7330d72
Show file tree
Hide file tree
Showing 9 changed files with 24,227 additions and 160 deletions.
22,685 changes: 22,561 additions & 124 deletions client/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/src/components/LinkDisplay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ThemeContext } from '../../ThemeContext';
import { LinkObjType } from '@chat-e2ee/service';

const LinkDisplay: React.FC<{ content: LinkObjType}> = ( { content } ) => {
const chatLink = content.absoluteLink || `${window.location.protocol}//${window.location.host}/${content.hash}`;
const chatLink = content.absoluteLink || `${window.location.protocol}//${window.location.host}/chat/${content.hash}`;
const textAreaRef = useRef<HTMLInputElement | null>(null);
const [buttonText, setButtonText] = useState("Copy");
const [darkMode] = useContext(ThemeContext);
Expand Down
15 changes: 7 additions & 8 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, SOCKET_LISTENERS } from "@chat-e2ee/service";
import { createChatInstance, generateUUID, cryptoUtils } from "@chat-e2ee/service";

import {
getUserSessionID,
Expand All @@ -17,7 +17,6 @@ import { Message, UserStatusInfo, NewMessageForm, ScrollWrapper } from "../../co
import Notification from "../../components/Notification";
import LinkSharingInstruction from "../../components/Messaging/LinkSharingInstruction";
import notificationAudio from "../../components/Notification/audio.mp3";
import { Timestamp } from "mongodb";
import { LS, SS } from "../../utils/storage";

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

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

//handle incoming message
chate2ee.on(
SOCKET_LISTENERS.CHAT_MESSAGE,
"chat-message",
async (msg: {
message: string;
image: string;
sender: string;
id: string;
timestamp: Timestamp;
timestamp: number;
}) => {
if(!myKeyRef.current?.privateKey) {
throw new Error("Private key not found!");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "concurrently \"npm run client\" \"npm run server\" \"npm run watch-sdk\"",
"dev": "concurrently \"npm run client\" \"npm run server\"",
"build-client": "cd client && npm run build",
"build": "tsc && npm run build-client",
"client": "cd client && npm start",
Expand Down
Loading

0 comments on commit 7330d72

Please sign in to comment.