diff --git a/examples/community/index.tsx b/examples/community/index.tsx index 274fa6be..73015954 100644 --- a/examples/community/index.tsx +++ b/examples/community/index.tsx @@ -1,10 +1,7 @@ import React, { StrictMode } from 'react' import { render } from 'react-dom' -// FIXME!: fixme from; Unable to resolve path to module '@status-im/react' import { Community } from '@status-im/react' -// TODO?: import/rename Chats, Messages, Messenger -// TODO?: import/rename CommunityAndMessenger, or Status even const App = () => { return ( diff --git a/packages/status-js/src/client.ts b/packages/status-js/src/client.ts index 02ec5dc2..13492bce 100644 --- a/packages/status-js/src/client.ts +++ b/packages/status-js/src/client.ts @@ -2,24 +2,6 @@ * @see https://specs.status.im/spec/1 */ -// todo: write class for channels/chat -// todo: use Map - -// todo: use single proto runtime - -// todo: tests - -// todo: handle disconnections; no messages after sleep; libp2p; -// todo: identities/members? -// todo?: observe channels -// todo?: rename channels to chats -// todo?: multiple communityCallback -// todo?: call onChannel* separately -// todo?: ignore messages of not yet approved users -// todo?: ignore messages with invalid signature -// todo?: handle encrypted waku messages -// todo?: handle waku messages/events without identity - import { hexToBytes } from 'ethereum-cryptography/utils' import { Waku, WakuMessage } from 'js-waku' diff --git a/packages/status-js/src/client/community/community.ts b/packages/status-js/src/client/community/community.ts index 8597f401..3bb24ec6 100644 --- a/packages/status-js/src/client/community/community.ts +++ b/packages/status-js/src/client/community/community.ts @@ -18,7 +18,6 @@ import type { Waku } from 'js-waku' export type CommunityMetadataType = CommunityDescription['proto'] -// todo?: rename to ChatMessageType export type MessageType = ChatMessage & { messageId: string pinned: boolean @@ -31,7 +30,6 @@ export class Community { private client: Client private waku: Waku public communityPublicKey: string - // fixme! private communityContentTopic!: string private communityDecryptionKey!: Uint8Array public communityMetadata!: CommunityMetadataType // state @@ -102,14 +100,12 @@ export class Community { return communityMetadata } - // todo?: rename and implement as "fetch history" (e.g. emojis, however, would arrive first and not match) public createFetchChannelMessages = async ( channelId: string, callback: (messages: MessageType[]) => void ) => { const id = `${this.communityPublicKey}${channelId}` const channelContentTopic = idToContentTopic(id) - // todo?: keep in state instead and replace the factory const symKey = await createSymKeyFromPassword(id) return async (options: { start: Date }) => { @@ -176,7 +172,6 @@ export class Community { const symKey = await createSymKeyFromPassword(id) - // todo?: request waku feature to be passed as param this.waku.relay.addDecryptionKey(symKey, { method: waku_message.DecryptionMethod.Symmetric, contentTopics: [channelContentTopic], @@ -226,7 +221,6 @@ export class Community { } // Community - // fixme!: set only if updated this.communityMetadata = communityMetadata this.communityCallback?.(communityMetadata) } @@ -283,7 +277,6 @@ export class Community { this.channelMessages[channelId] = _messages // callback - // todo!: review use of ! why not just use messages defined above? this.channelMessagesCallbacks[channelId]?.(this.channelMessages[channelId]!) } diff --git a/packages/status-js/src/client/community/handle-waku-message.ts b/packages/status-js/src/client/community/handle-waku-message.ts index 96bd8070..8053fc16 100644 --- a/packages/status-js/src/client/community/handle-waku-message.ts +++ b/packages/status-js/src/client/community/handle-waku-message.ts @@ -1,6 +1,3 @@ -// todo: move file -// fixme: relative paths - import { bytesToHex } from 'ethereum-cryptography/utils' import { ApplicationMetadataMessage } from '../../../protos/application-metadata-message' @@ -24,17 +21,6 @@ import type { Client } from '../../client' import type { Community /*, MessageType*/ } from './community' import type { WakuMessage } from 'js-waku' -// todo?: return decoded, possibly mapped, event but do not update state and call callback -// todo?: return void -// todo?: return success (e.g. if this handler should be used in Community's init) -// fixme: -/** - * Argument of type '(wakuMessage: WakuMessage, community: Community) => boolean' - * is not assignable to parameter of type '(message: WakuMessage) => void'.ts(2345) - */ -// type HandlerResult = boolean -// type HandlerResult = CommunityDescription | MessageType | undefined - export function handleWakuMessage( wakuMessage: WakuMessage, // state @@ -47,7 +33,6 @@ export function handleWakuMessage( return } - // todo: explain if (!wakuMessage.signaturePublicKey) { return } @@ -72,7 +57,6 @@ export function handleWakuMessage( decodedMetadata.payload ) - // fixme?: handle decodedProtocol.encryptedMessage const wakuMessageId = payloadToId( decodedProtocol?.publicMessage || decodedMetadata.payload, publicKey @@ -91,7 +75,6 @@ export function handleWakuMessage( // decode const decodedPayload = CommunityDescription.decode(messageToDecode) - // todo?: don't use class method // handle (state and callback) community.handleCommunityMetadataEvent(decodedPayload) @@ -107,7 +90,6 @@ export function handleWakuMessage( // TODO?: ignore community.channelMessages which are messageType !== COMMUNITY_CHAT // map - // todo?: use full chatId (incl. pub key) instead const channelId = getChannelId(decodedPayload.chatId) const chatMessage = mapChatMessage(decodedPayload, { @@ -129,7 +111,6 @@ export function handleWakuMessage( const messageId = decodedPayload.messageId const channelId = getChannelId(decodedPayload.chatId) - // todo?: move to class method (e.g. handleChannelChatMessageEditEvent) const _messages = community.channelMessages[channelId] || [] let index = _messages.length @@ -148,10 +129,8 @@ export function handleWakuMessage( const _message = _messages[index] - // todo?: use mapChatMessage const message = { ..._message, - // fixme?: other fields that user can edit text: decodedPayload.text, } @@ -192,7 +171,6 @@ export function handleWakuMessage( break } - // todo?: use delete; set to null _messages.splice(index, 1) // state @@ -236,7 +214,6 @@ export function handleWakuMessage( community.channelMessages[channelId] = _messages // callback - // todo!: review use of ! community.channelMessagesCallbacks[channelId]?.( community.channelMessages[channelId]! ) @@ -272,7 +249,6 @@ export function handleWakuMessage( const isMe = account?.publicKey === `0x${bytesToHex(wakuMessage.signaturePublicKey)}` - // fixme! _messages[index].reactions = getReactions( decodedPayload, _message.reactions, diff --git a/packages/status-js/src/messenger.spec.ts b/packages/status-js/src/messenger.spec.ts index 158813f8..f3ce3476 100644 --- a/packages/status-js/src/messenger.spec.ts +++ b/packages/status-js/src/messenger.spec.ts @@ -23,7 +23,6 @@ describe('Messenger', () => { identityAlice = Identity.generate() identityBob = Identity.generate() - // todo: mock/provide WakuMock dbg('Create messengers') ;[messengerAlice, messengerBob] = await Promise.all([ Messenger.create(identityAlice, { bootstrap: {} }), diff --git a/packages/status-js/src/messenger.ts b/packages/status-js/src/messenger.ts index f3934b89..319b672d 100644 --- a/packages/status-js/src/messenger.ts +++ b/packages/status-js/src/messenger.ts @@ -1,5 +1,5 @@ import debug from 'debug' -import { waku_message, WakuMessage } from 'js-waku' +import { Waku, waku_message, WakuMessage } from 'js-waku' import { Chat } from './chat' import { ApplicationMetadataMessage_Type } from './proto/status/v1/application_metadata_message' @@ -9,11 +9,10 @@ import { ChatMessage } from './wire/chat_message' import type { Identity } from './identity' import type { Content } from './wire/chat_message' -import type { Waku } from 'js-waku' +import type { waku } from 'js-waku' const dbg = debug('communities:messenger') -// TODO: pass waku client export class Messenger { waku: Waku chatsById: Map @@ -37,8 +36,6 @@ export class Messenger { public static async create( identity: Identity | undefined, - // wakuOptions?: waku.CreateOptions - // TODO: pass waku as client wakuOptions?: waku.CreateOptions ): Promise { const _wakuOptions = Object.assign( diff --git a/packages/status-js/src/wire/community_description.ts b/packages/status-js/src/wire/community_description.ts index 32b1d519..a7c0df84 100644 --- a/packages/status-js/src/wire/community_description.ts +++ b/packages/status-js/src/wire/community_description.ts @@ -42,7 +42,6 @@ export class CommunityDescription { const callback = (messages: WakuMessage[]): void => { // Value found, stop processing - // FIXME?: return true/false if (communityDescription) return // Process most recent message first @@ -67,8 +66,6 @@ export class CommunityDescription { ) } }) - - // FIXME?: return true/false } const symKey = await createSymKeyFromPassword(hexCommunityPublicKey)