refactor(contacts): Refactor contacts to efficient data fetching

This commit is contained in:
Taso committed 2021-06-08 14:58:05 -04:00
1 parent 54d456cc8a
commit d036243d64
29 files changed
+417 -352

No files matched your search

@@ -1,7 +1,7 @@
import React from 'react';
import { Avatar, Box, Typography } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import { useContacts } from '../../../apps/contacts/hooks/useContacts';
import { useContactActions } from '../../../apps/contacts/hooks/useContactActions';
import { useCall } from '../hooks/useCall';
import { useTranslation } from 'react-i18next';
@@ -17,7 +17,7 @@ const CallContactContainer = () => {
const { call } = useCall();
const classes = useStyles();
const { getDisplayByNumber, getPictureByNumber } = useContacts();
const { getDisplayByNumber, getPictureByNumber } = useContactActions();
const getDisplayOrNumber = () =>
call.isTransmitter ? getDisplayByNumber(call?.receiver) : getDisplayByNumber(call?.transmitter);
+16
View File
@@ -0,0 +1,16 @@
import { useEffect, useState } from 'react';
export const useDebounce = <T = any>(value: T, delay = 100) => {
const [debouncedValue, setDebouncedValue] = useState(value);
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value);
}, delay);
return () => {
clearTimeout(handler);
};
}, [value, delay]);
return debouncedValue;
};