Skip to content

Commit

Permalink
fix: remove sync feature, allow same contact reimport
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarbazz committed Jul 29, 2023
1 parent 548dbd8 commit 00f55c4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 97 deletions.
18 changes: 2 additions & 16 deletions app/contact-import.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,17 @@ import {
} from '@ui-kitten/components'
import { useRouter } from 'expo-router'
import { StyledComponent } from 'nativewind'
import { useMemo } from 'react'

import ContactImportList from '../src/components/ContactImport/ContactImportSearch'
import EmptyView from '../src/components/EmptyView'
import SafeAreaView from '../src/components/SafeAreaView'
import { usePalsContacts } from '../src/contexts/PalsContacts'
import useDeviceContacts from '../src/hooks/useDeviceContacts'

const ContactImport = () => {
const deviceContacts = useDeviceContacts(
'to start adding contacts into Pals.',
)
const [palsContacts] = usePalsContacts()
const router = useRouter()
// Exclude contacts that are already imported
const contactsToImport = useMemo(
() =>
deviceContacts?.filter(
(deviceContact) =>
!palsContacts.find(
(palsContact) => palsContact.id === deviceContact.id,
),
),
[deviceContacts, palsContacts],
)

return (
<SafeAreaView>
Expand All @@ -56,8 +42,8 @@ const ContactImport = () => {
title="Contact Import"
/>
<Divider />
{contactsToImport?.length ? (
<ContactImportList contactsToImport={contactsToImport} />
{deviceContacts?.length ? (
<ContactImportList contactsToImport={deviceContacts} />
) : (
<EmptyView bodyText="You have no contacts to import." />
)}
Expand Down
2 changes: 0 additions & 2 deletions app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import {
} from '../src/contexts/PalsContactsList'
import { exportPalsDataToFs, importPalsDataToApp } from '../src/fsHelpers'
import useLoadPalsContacts from '../src/hooks/useLoadPalsContacts'
import useSyncPalsContacts from '../src/hooks/useSyncPalsContacts'

const MainScreen = () => {
const [selectedPalsContactListIndex, setSelectedPalsContactListIndex] =
usePalsContactsList()
const [palsContacts, setPalsContacts] = usePalsContacts()
useLoadPalsContacts()
useSyncPalsContacts()

return (
<SafeAreaView>
Expand Down
5 changes: 3 additions & 2 deletions src/contactsHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AsyncStorage from '@react-native-async-storage/async-storage'
import * as Contacts from 'expo-contacts'
import * as Crypto from 'expo-crypto'
import { Alert } from 'react-native'

import { DEFAULT_ALERT_BUTTON_TEXT, PALS_CONTACTS_KEY } from './constants'
Expand Down Expand Up @@ -60,9 +61,9 @@ export const addPalsContactToStorage = async (
selectedListName: PalsContactListName,
) => {
// This is where we pick the fields we want to store
const { id, name, image } = contact
const { name, image } = contact
const newPalsContact: PalsContact = {
id,
id: Crypto.randomUUID(),
name,
image,
interactions: [],
Expand Down
77 changes: 0 additions & 77 deletions src/hooks/useSyncPalsContacts.ts

This file was deleted.

0 comments on commit 00f55c4

Please sign in to comment.