diff --git a/api/queue.tsx b/api/queue.tsx index 61665c4b..f859759b 100644 --- a/api/queue.tsx +++ b/api/queue.tsx @@ -29,6 +29,9 @@ class PromiseQueue { // happen. const quizQueue = new PromiseQueue(); +const aboutQueue = new PromiseQueue(); + export { + aboutQueue, quizQueue, }; diff --git a/components/profile-tab.tsx b/components/profile-tab.tsx index f110ebc2..6c56cd28 100644 --- a/components/profile-tab.tsx +++ b/components/profile-tab.tsx @@ -43,6 +43,7 @@ import { } from '../env/env'; import * as _ from "lodash"; import debounce from 'lodash/debounce'; +import { aboutQueue } from '../api/queue'; const formatHeight = (og: OptionGroup): string | undefined => { if (!isOptionGroupSlider(og.input)) return ''; @@ -155,19 +156,22 @@ const ProfileTab_ = ({navigation}) => { ); }; +const enqueueAbout = async (about: string, cb: (ok: boolean) => void) => { + aboutQueue.addTask( + async () => { + const response = await japi('patch', '/profile-info', { about }); + cb(response.ok); + } + ); +}; + const AboutPerson = ({navigation, data}) => { const [aboutState, setAboutState] = useState< 'unchanged' | 'saving...' | 'saved' | 'error' >('unchanged'); const debouncedOnChangeAboutText = useCallback( - debounce( - async (about: string, cb: (ok: boolean) => void) => { - const response = await japi('patch', '/profile-info', { about }); - cb(response.ok); - }, - 1000, - ), + debounce(enqueueAbout, 1000), [] );