Skip to content

Commit

Permalink
Adjust code to display multiple addresses in invitation url
Browse files Browse the repository at this point in the history
tsconfig - change target to es2020, add dom.iterable to lib options
  • Loading branch information
EmiM committed Aug 11, 2023
1 parent ee91ad1 commit 525383a
Show file tree
Hide file tree
Showing 11 changed files with 253 additions and 250 deletions.
6 changes: 3 additions & 3 deletions packages/common/src/invitationCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { multiaddr } from 'multiaddr'

export const retrieveInvitationCode = (url: string): InvitationPair[] => {
/**
* Extract invitation code from deep url.
* Extract invitation codes from deep url.
* Valid format: quiet://?<peerid1>=<address1>&<peerid2>=<addresss2>
*/
let data: URL
Expand All @@ -36,7 +36,7 @@ export const retrieveInvitationCode = (url: string): InvitationPair[] => {
if (!data || data.protocol !== 'quiet:') return []
const params = data.searchParams
const codes: InvitationPair[] = []
for (const [peerId, address] of params) {
for (const [peerId, address] of params.entries()) {
// TODO: basic check if peerid and address have proper format?
if (peerId.length !== 46 || address.length !== 56) {
console.log(`peerId '${peerId}' or address ${address} is not valid`)
Expand Down Expand Up @@ -90,7 +90,7 @@ export const argvInvitationCode = (argv: string[]): InvitationPair[] => {
/**
* Extract invitation codes from deep url if url is present in argv
*/
let invitationCodes = []
let invitationCodes: InvitationPair[] = []
for (const arg of argv) {
invitationCodes = retrieveInvitationCode(arg)
if (invitationCodes.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { select, put, delay } from 'typed-redux-saga'
import { CommunityOwnership, CreateNetworkPayload } from '@quiet/types'
import { communities } from '@quiet/state-manager'
import { socketSelectors } from '../socket/socket.selectors'
import { ONION_ADDRESS_REGEX } from '@quiet/common'
import { ModalName } from '../modals/modals.types'
import { modalsActions } from '../modals/modals.slice'

Expand Down
1 change: 1 addition & 0 deletions packages/desktop/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"allowJs": true,
"lib": [
"ES2020",
"DOM.Iterable",
"dom"
],
"typeRoots": [
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "es2017",
"target": "ES2020",
"outDir": "./lib",
"typeRoots": [
"../@types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const InvitationContextMenu: FC = () => {

const screen = useSelector(navigationSelectors.currentScreen)

const community = useSelector(communities.selectors.currentCommunity)
// const community = useSelector(communities.selectors.currentCommunity)
const invitationLink = useSelector(communities.selectors.invitationUrl)

const invitationContextMenu = useContextMenu(MenuName.Invitation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { FC, useCallback, useEffect, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { identity, communities } from '@quiet/state-manager'
import { CommunityOwnership, CreateNetworkPayload } from '@quiet/types'
import { CommunityOwnership, CreateNetworkPayload, InvitationPair } from '@quiet/types'
import { JoinCommunity } from '../../components/JoinCommunity/JoinCommunity.component'
import { navigationActions } from '../../store/navigation/navigation.slice'
import { ScreenNames } from '../../const/ScreenNames.enum'
Expand Down Expand Up @@ -35,10 +35,10 @@ export const JoinCommunityScreen: FC<JoinCommunityScreenProps> = ({ route }) =>
}, [dispatch, community, route.params?.code])

const joinCommunityAction = useCallback(
(address: string) => {
(pairs: InvitationPair[]) => {
const payload: CreateNetworkPayload = {
ownership: CommunityOwnership.User,
registrar: address,
peers: pairs,
}
dispatch(communities.actions.createNetwork(payload))
dispatch(
Expand Down
Loading

0 comments on commit 525383a

Please sign in to comment.