mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
fix optimization issue in reply and quote buttons
This commit is contained in:
1 parent
585eb43f4e
commit
fb6ce054fc
9 files changed
+48
-37
No files matched your search
@@ -21,12 +21,12 @@ export const twitterState = {
|
||||
key: "createTweetLoading",
|
||||
default: false,
|
||||
}),
|
||||
createTweetSuccess: atom({
|
||||
key: "createTweetSuccess",
|
||||
createTweetSuccessful: atom({
|
||||
key: "createTweetSuccessful",
|
||||
default: null,
|
||||
}),
|
||||
updateProfileLoading: atom({
|
||||
key: "createTweetLoading",
|
||||
key: "updateProfileLoading",
|
||||
default: false,
|
||||
}),
|
||||
updateProfileSuccess: atom({
|
||||
|
||||
@@ -3,9 +3,16 @@ import { twitterState } from "./state";
|
||||
|
||||
export const useProfile = () => {
|
||||
const profile = useRecoilValue(twitterState.profile);
|
||||
const updateInProgress = useRecoilValue(twitterState.updateProfileLoading);
|
||||
const [updateSuccessful, setUpdateSuccessful] = useRecoilState(
|
||||
const updateProfileLoading = useRecoilValue(
|
||||
twitterState.updateProfileLoading
|
||||
);
|
||||
const [updateProfileSuccessful, setUpdateProfileSuccessful] = useRecoilState(
|
||||
twitterState.updateProfileSuccess
|
||||
);
|
||||
return { profile, updateInProgress, updateSuccessful, setUpdateSuccessful };
|
||||
return {
|
||||
profile,
|
||||
updateProfileLoading,
|
||||
updateProfileSuccessful,
|
||||
setUpdateProfileSuccessful,
|
||||
};
|
||||
};
|
||||
@@ -3,9 +3,13 @@ import { useRecoilValue, useRecoilState } from "recoil";
|
||||
import { twitterState } from "./state";
|
||||
|
||||
export const useTweetStatus = () => {
|
||||
const isLoading = useRecoilValue(twitterState.createTweetLoading);
|
||||
const [isSuccessful, setIsSuccessful] = useRecoilState(
|
||||
twitterState.createTweetSuccess
|
||||
const createTweetLoading = useRecoilValue(twitterState.createTweetLoading);
|
||||
const [createTweetSuccessful, setCreateTweetSuccessful] = useRecoilState(
|
||||
twitterState.createTweetSuccessful
|
||||
);
|
||||
return { isLoading, isSuccessful, setIsSuccessful };
|
||||
return {
|
||||
createTweetLoading,
|
||||
createTweetSuccessful,
|
||||
setCreateTweetSuccessful,
|
||||
};
|
||||
};
|
||||
@@ -38,13 +38,14 @@ export const useTwitterService = () => {
|
||||
);
|
||||
const setTweets = useSetRecoilState(twitterState.tweets);
|
||||
const setCreateLoading = useSetRecoilState(twitterState.createTweetLoading);
|
||||
const setCreateSuccess = useSetRecoilState(twitterState.createTweetSuccess);
|
||||
const setCreateSuccess = useSetRecoilState(
|
||||
twitterState.createTweetSuccessful
|
||||
);
|
||||
|
||||
const _setProfile = (profile) => {
|
||||
setProfile(profile[0]); // server returns an array of 1 profile
|
||||
};
|
||||
const _setUpdateProfileSuccess = (isSuccessful) => {
|
||||
console.log("got: ", isSuccessful);
|
||||
setUpdateProfileSuccess(isSuccessful);
|
||||
setUpdateProfileLoading(false); // on any result we should set loading to false
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user