mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
refactor(contacts): Refactor contacts to efficient data fetching
This commit is contained in:
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);
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
Reference in new issue
Block a user