mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
working profile and editing of profile
This commit is contained in:
1 parent
5072a31aab
commit
9fe4cf0188
27 files changed
+459
-51
No files matched your search
@@ -17,4 +17,12 @@ export const twitterState = {
|
||||
key: "createTweetSuccess",
|
||||
default: null,
|
||||
}),
|
||||
updateProfileLoading: atom({
|
||||
key: "createTweetLoading",
|
||||
default: false,
|
||||
}),
|
||||
updateProfileSuccess: atom({
|
||||
key: "createTweetSuccess",
|
||||
default: null,
|
||||
}),
|
||||
};
|
||||
@@ -3,5 +3,7 @@ import { twitterState } from "./state";
|
||||
|
||||
export const useProfile = () => {
|
||||
const profile = useRecoilValue(twitterState.profile);
|
||||
return { profile };
|
||||
const updateInProgress = useRecoilValue(twitterState.updateProfileLoading);
|
||||
const updateSuccessful = useRecoilValue(twitterState.updateProfileSuccess);
|
||||
return { profile, updateInProgress, updateSuccessful };
|
||||
};
|
||||
@@ -30,6 +30,12 @@ function processTweet(tweet) {
|
||||
*/
|
||||
export const useTwitterService = () => {
|
||||
const setProfile = useSetRecoilState(twitterState.profile);
|
||||
const setUpdateProfileLoading = useSetRecoilState(
|
||||
twitterState.updateProfileLoading
|
||||
);
|
||||
const setUpdateProfileSuccess = useSetRecoilState(
|
||||
twitterState.updateProfileSuccess
|
||||
);
|
||||
const setTweets = useSetRecoilState(twitterState.tweets);
|
||||
const setCreateLoading = useSetRecoilState(twitterState.createTweetLoading);
|
||||
const setCreateSuccess = useSetRecoilState(twitterState.createTweetSuccess);
|
||||
@@ -37,10 +43,14 @@ export const useTwitterService = () => {
|
||||
const _setProfile = (profile) => {
|
||||
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
|
||||
setUpdateProfileLoading(false); // on any result we should set loading to false
|
||||
};
|
||||
|
||||
const _setCreateSuccess = (isSuccessful) => {
|
||||
setCreateSuccess(isSuccessful === 1); // numeric 1 is returned by MySQL on successful query
|
||||
setCreateLoading(false); // on any result we should set loading to false
|
||||
setCreateSuccess(isSuccessful === 1);
|
||||
setCreateLoading(false);
|
||||
};
|
||||
|
||||
const _setTweets = (tweets) => {
|
||||
@@ -48,6 +58,16 @@ export const useTwitterService = () => {
|
||||
};
|
||||
|
||||
useNuiEvent(types.APP_TWITTER, "getOrCreateTwitterProfile", _setProfile);
|
||||
useNuiEvent(
|
||||
types.APP_TWITTER,
|
||||
"updateProfileLoading",
|
||||
setUpdateProfileLoading
|
||||
);
|
||||
useNuiEvent(
|
||||
types.APP_TWITTER,
|
||||
"updateProfileResult",
|
||||
_setUpdateProfileSuccess
|
||||
);
|
||||
useNuiEvent(types.APP_TWITTER, "fetchTweets", _setTweets);
|
||||
useNuiEvent(types.APP_TWITTER, "createTweetLoading", setCreateLoading);
|
||||
useNuiEvent(types.APP_TWITTER, "createTweetResult", _setCreateSuccess);
|
||||
|
||||
Reference in new issue
Block a user