reject call after 1 minute showing the dialog
parent
4700a0c832
commit
57449857f6
@ -0,0 +1,17 @@
|
|||||||
|
import React from 'react';
|
||||||
|
// tslint:disable-next-line: no-submodule-imports
|
||||||
|
import useInterval from 'react-use/lib/useInterval';
|
||||||
|
|
||||||
|
export function useModulo(loopBackAt: number, delay: number) {
|
||||||
|
const [count, setCount] = React.useState(0);
|
||||||
|
|
||||||
|
useInterval(() => {
|
||||||
|
if (count >= loopBackAt) {
|
||||||
|
setCount(0);
|
||||||
|
} else {
|
||||||
|
setCount(count + 1);
|
||||||
|
}
|
||||||
|
}, delay);
|
||||||
|
console.warn('useModulo', count);
|
||||||
|
return { count };
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
import { useModulo } from './useModulo';
|
||||||
|
|
||||||
|
export function useModuloWithTripleDots(
|
||||||
|
localizedString: string,
|
||||||
|
loopBackAt: number,
|
||||||
|
delay: number
|
||||||
|
) {
|
||||||
|
const modulo = useModulo(loopBackAt, delay);
|
||||||
|
|
||||||
|
if (localizedString.endsWith('...')) {
|
||||||
|
return localizedString.slice(0, localizedString.length - (loopBackAt - modulo.count));
|
||||||
|
}
|
||||||
|
return localizedString;
|
||||||
|
}
|
Loading…
Reference in New Issue