diff --git a/CHANGELOG.md b/CHANGELOG.md index 637c866c11..9a0e5e3cdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,8 @@ [unreleased] -* Shorter dots-placeholder for invite link - +* Fixed mobile bugs - joining by QR code and not showing username taken screen for user who has unique name -[Unreleased] +* Shorter dots-placeholder for invite link * Revert adjusting bootstrap scripts for developing on Windows diff --git a/packages/mobile/src/components/UserLabel/Duplicated/DuplicatedUsername.test.tsx b/packages/mobile/src/components/UserLabel/Duplicated/DuplicatedUsername.test.tsx index ce162d56d7..d6d1ca16bb 100644 --- a/packages/mobile/src/components/UserLabel/Duplicated/DuplicatedUsername.test.tsx +++ b/packages/mobile/src/components/UserLabel/Duplicated/DuplicatedUsername.test.tsx @@ -282,8 +282,8 @@ describe('DuplicatedUsername component', () => { style={ { "height": 12, + "marginLeft": 4, "marginRight": 4, - "merginLeft": 4, "width": 13, } } diff --git a/packages/mobile/src/components/UserLabel/UserLabel.component.tsx b/packages/mobile/src/components/UserLabel/UserLabel.component.tsx index 537d098910..9e289a0aa1 100644 --- a/packages/mobile/src/components/UserLabel/UserLabel.component.tsx +++ b/packages/mobile/src/components/UserLabel/UserLabel.component.tsx @@ -38,7 +38,7 @@ const classes = StyleSheet.create({ width: 13, height: 12, marginRight: 4, - merginLeft: 4, + marginLeft: 4, }, }) diff --git a/packages/mobile/src/components/UserLabel/UserLabel.test.tsx b/packages/mobile/src/components/UserLabel/UserLabel.test.tsx index 28e4c81a4f..5bd06882de 100644 --- a/packages/mobile/src/components/UserLabel/UserLabel.test.tsx +++ b/packages/mobile/src/components/UserLabel/UserLabel.test.tsx @@ -62,8 +62,8 @@ describe('UserLabel component', () => { style={ { "height": 12, + "marginLeft": 4, "marginRight": 4, - "merginLeft": 4, "width": 13, } } diff --git a/packages/mobile/src/route.params.ts b/packages/mobile/src/route.params.ts index 2813798728..8221547080 100644 --- a/packages/mobile/src/route.params.ts +++ b/packages/mobile/src/route.params.ts @@ -4,9 +4,7 @@ import { ScreenNames } from './const/ScreenNames.enum' // eslint-disable-next-line export type RootStackParamList = { - [ScreenNames.SplashScreen]: { - code?: string - } + [ScreenNames.SplashScreen]: undefined [ScreenNames.JoinCommunityScreen]: { code?: string } diff --git a/packages/mobile/src/screens/Splash/Splash.screen.tsx b/packages/mobile/src/screens/Splash/Splash.screen.tsx index 5df07a9160..f5e55d6435 100644 --- a/packages/mobile/src/screens/Splash/Splash.screen.tsx +++ b/packages/mobile/src/screens/Splash/Splash.screen.tsx @@ -11,15 +11,19 @@ export const SplashScreen: FC = ({ route }) => { const ready = useSelector(initSelectors.ready) useEffect(() => { - const code = route.params?.code + let code = route.path // Screen hasn't been open through a link if (!code) return + if (code.charAt(0) === '?') { + code = code.slice(1, code.length) + } + if (ready) { dispatch(initActions.deepLink(code)) } - }, [ready, route.params?.code]) + }, [ready, route.path]) return } diff --git a/packages/mobile/src/tests/splash.screen.test.tsx b/packages/mobile/src/tests/splash.screen.test.tsx index 2b2970ef1e..c84567b89d 100644 --- a/packages/mobile/src/tests/splash.screen.test.tsx +++ b/packages/mobile/src/tests/splash.screen.test.tsx @@ -25,12 +25,10 @@ describe('Splash screen', () => { const invitationCode = 'QmZoiJNAvCffeEHBjk766nLuKVdkxkAT7wfFJDPPLsbKSE=y7yczmugl2tekami7sbdz5pfaemvx7bahwthrdvcbzw5vex2crsr26qd' - const route: { key: string; name: ScreenNames.SplashScreen; params: { code?: string } } = { + const route: { key: string; name: ScreenNames.SplashScreen; path: string } = { key: '', name: ScreenNames.SplashScreen, - params: { - code: invitationCode, - }, + path: invitationCode, } renderComponent( diff --git a/packages/state-manager/src/sagas/communities/communities.selectors.test.ts b/packages/state-manager/src/sagas/communities/communities.selectors.test.ts index 966e5cd3f2..50233bbe90 100644 --- a/packages/state-manager/src/sagas/communities/communities.selectors.test.ts +++ b/packages/state-manager/src/sagas/communities/communities.selectors.test.ts @@ -125,6 +125,12 @@ describe('communitiesSelectors', () => { certificates: [identity.userCertificate || ''], }) ) + + store.dispatch( + usersActions.setAllCerts({ + certificates: [identity.userCertificate || ''], + }) + ) const ownerNickname = communitiesSelectors.ownerNickname(store.getState()) expect(ownerNickname).toEqual(identity.nickname) }) diff --git a/packages/state-manager/src/sagas/identity/updateCertificate/updateCertificate.saga.ts b/packages/state-manager/src/sagas/identity/updateCertificate/updateCertificate.saga.ts index a03438bd5d..350307a1af 100644 --- a/packages/state-manager/src/sagas/identity/updateCertificate/updateCertificate.saga.ts +++ b/packages/state-manager/src/sagas/identity/updateCertificate/updateCertificate.saga.ts @@ -5,29 +5,29 @@ import { identitySelectors } from '../identity.selectors' import { loadCSR, pubKeyMatch } from '@quiet/identity' import { identityActions } from '../identity.slice' import { communitiesSelectors } from '../../communities/communities.selectors' +import { usersActions } from '../../users/users.slice' export function* updateCertificateSaga(action: PayloadAction): Generator { const certificate = yield* select(identitySelectors.hasCertificate) const communityId = yield* select(communitiesSelectors.currentCommunityId) - - if (certificate) return - const csr = yield* select(identitySelectors.csr) - if (!csr?.userCsr) return + if (!certificate && csr?.userCsr) { + const parsedCsr = yield* call(loadCSR, csr?.userCsr) - const parsedCsr = yield* call(loadCSR, csr?.userCsr) + const cert = action.payload.certificates.find(cert => { + if (pubKeyMatch(cert, parsedCsr)) return cert + }) - const cert = action.payload.certificates.find(cert => { - if (pubKeyMatch(cert, parsedCsr)) return cert - }) - - if (cert) { - yield* put( - identityActions.storeUserCertificate({ - userCertificate: cert, - communityId, - }) - ) + if (cert) { + yield* put( + identityActions.storeUserCertificate({ + userCertificate: cert, + communityId, + }) + ) + } } + + yield* put(usersActions.setAllCerts(action.payload)) } diff --git a/packages/state-manager/src/sagas/users/users.slice.test.ts b/packages/state-manager/src/sagas/users/users.slice.test.ts index 8beaa59807..aeb64ea22a 100644 --- a/packages/state-manager/src/sagas/users/users.slice.test.ts +++ b/packages/state-manager/src/sagas/users/users.slice.test.ts @@ -60,6 +60,12 @@ describe('users reducer', () => { }) ) + store.dispatch( + usersActions.setAllCerts({ + certificates: [userCertString], + }) + ) + const certificates = usersSelectors.certificates(store.getState()) expect(certificates[userPubKey]).toEqual(parsedCert) diff --git a/packages/state-manager/src/sagas/users/users.slice.ts b/packages/state-manager/src/sagas/users/users.slice.ts index 75e56531f3..27ecdf1e65 100644 --- a/packages/state-manager/src/sagas/users/users.slice.ts +++ b/packages/state-manager/src/sagas/users/users.slice.ts @@ -17,7 +17,9 @@ export const usersSlice = createSlice({ storeUserCertificate: (state, action: PayloadAction<{ certificate: string }>) => { certificatesAdapter.addOne(state.certificates, parseCertificate(action.payload.certificate)) }, - responseSendCertificates: (state, action: PayloadAction) => { + responseSendCertificates: (state, action: PayloadAction) => {}, + + setAllCerts: (state, action: PayloadAction) => { certificatesAdapter.setAll( state.certificates, Object.values(action.payload.certificates).map(item => {