mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
working callbacks and status updates on user interaction with the database
This commit is contained in:
1 parent
1157906def
commit
585eb43f4e
18 files changed
+139
-63
No files matched your search
@@ -30,7 +30,7 @@ export const twitterState = {
|
||||
default: false,
|
||||
}),
|
||||
updateProfileSuccess: atom({
|
||||
key: "createTweetSuccess",
|
||||
key: "updateProfileSuccess",
|
||||
default: null,
|
||||
}),
|
||||
};
|
||||
@@ -1,9 +1,11 @@
|
||||
import { useRecoilValue } from "recoil";
|
||||
import { useRecoilValue, useRecoilState } from "recoil";
|
||||
import { twitterState } from "./state";
|
||||
|
||||
export const useProfile = () => {
|
||||
const profile = useRecoilValue(twitterState.profile);
|
||||
const updateInProgress = useRecoilValue(twitterState.updateProfileLoading);
|
||||
const updateSuccessful = useRecoilValue(twitterState.updateProfileSuccess);
|
||||
return { profile, updateInProgress, updateSuccessful };
|
||||
const [updateSuccessful, setUpdateSuccessful] = useRecoilState(
|
||||
twitterState.updateProfileSuccess
|
||||
);
|
||||
return { profile, updateInProgress, updateSuccessful, setUpdateSuccessful };
|
||||
};
|
||||
@@ -1,9 +1,11 @@
|
||||
import { useRecoilValue } from "recoil";
|
||||
import { useRecoilValue, useRecoilState } from "recoil";
|
||||
|
||||
import { twitterState } from "./state";
|
||||
|
||||
export const useTweetStatus = () => {
|
||||
const isLoading = useRecoilValue(twitterState.createTweetLoading);
|
||||
const isSuccessful = useRecoilValue(twitterState.createTweetSuccess);
|
||||
return { isLoading, isSuccessful };
|
||||
const [isSuccessful, setIsSuccessful] = useRecoilState(
|
||||
twitterState.createTweetSuccess
|
||||
);
|
||||
return { isLoading, isSuccessful, setIsSuccessful };
|
||||
};
|
||||
@@ -44,12 +44,13 @@ export const useTwitterService = () => {
|
||||
setProfile(profile[0]); // server returns an array of 1 profile
|
||||
};
|
||||
const _setUpdateProfileSuccess = (isSuccessful) => {
|
||||
setUpdateProfileSuccess(isSuccessful === 1); // numeric 1 is returned by MySQL on successful query
|
||||
console.log("got: ", isSuccessful);
|
||||
setUpdateProfileSuccess(isSuccessful);
|
||||
setUpdateProfileLoading(false); // on any result we should set loading to false
|
||||
};
|
||||
|
||||
const _setCreateSuccess = (isSuccessful) => {
|
||||
setCreateSuccess(isSuccessful === 1);
|
||||
setCreateSuccess(isSuccessful);
|
||||
setCreateLoading(false);
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user