mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
moved twitter skeleton to TweetList
This commit is contained in:
1 parent
2a6429c446
commit
1d4faa4bf9
5 files changed
+25
-22
No files matched your search
@@ -37,15 +37,13 @@ const PAGE_COMPONENT_MAPPING = {
|
|||||||
1: <TwitterSearch />,
|
1: <TwitterSearch />,
|
||||||
2: <TwitterProfile />,
|
2: <TwitterProfile />,
|
||||||
};
|
};
|
||||||
const MINIMUM_LOAD_TIME = 500;
|
const TWEETS_REFRESH_RATE = 15000; // TODO move this to twitter config
|
||||||
const TWEETS_REFRESH_RATE = 50000000; // TODO move this to twitter config
|
|
||||||
|
|
||||||
export const TwitterApp = () => {
|
export const TwitterApp = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const { modalVisible, setModalVisible } = useModal();
|
const { modalVisible, setModalVisible } = useModal();
|
||||||
const [minimumLoadPassed, setMimimumLoadPassed] = useState(false);
|
|
||||||
const [activePage, setActivePage] = useState(0);
|
const [activePage, setActivePage] = useState(0);
|
||||||
const { profile } = useProfile();
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Nui.send("phone:getOrCreateTwitterProfile", {});
|
Nui.send("phone:getOrCreateTwitterProfile", {});
|
||||||
Nui.send("phone:fetchTweets", {});
|
Nui.send("phone:fetchTweets", {});
|
||||||
@@ -63,21 +61,9 @@ export const TwitterApp = () => {
|
|||||||
return () => window.clearTimeout(timeout);
|
return () => window.clearTimeout(timeout);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const timeout = window.setTimeout(() => {
|
|
||||||
setMimimumLoadPassed(true);
|
|
||||||
}, MINIMUM_LOAD_TIME);
|
|
||||||
return () => window.clearTimeout(timeout);
|
|
||||||
});
|
|
||||||
|
|
||||||
const openModal = () => setModalVisible(true);
|
const openModal = () => setModalVisible(true);
|
||||||
const handlePageChange = (e, page) => setActivePage(page);
|
const handlePageChange = (e, page) => setActivePage(page);
|
||||||
|
const showTweetButton = activePage === 0;
|
||||||
// we add a minimum (but short) load time here so that
|
|
||||||
// there isn't a quick flash of loading and immediately
|
|
||||||
// another flash to the tweets screen.
|
|
||||||
const hasLoaded = profile && minimumLoadPassed;
|
|
||||||
const showTweetButton = hasLoaded && activePage === 0;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppWrapper id="twitter-app">
|
<AppWrapper id="twitter-app">
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ function TwitterSearch() {
|
|||||||
inputRef={(input) => input && input.focus()}
|
inputRef={(input) => input && input.focus()}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<TweetList tweets={tweets || []} />
|
{tweets && tweets.length > 0 && <TweetList tweets={tweets} />}
|
||||||
</div>
|
</div>
|
||||||
<SearchButton handleClick={handleSubmit} />
|
<SearchButton handleClick={handleSubmit} />
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Nui from "../../../../os/nui-events/utils/Nui";
|
|||||||
import { useProfile } from "../../hooks/useProfile";
|
import { useProfile } from "../../hooks/useProfile";
|
||||||
import Avatar from "../Avatar";
|
import Avatar from "../Avatar";
|
||||||
import ProfileField from "./ProfileField";
|
import ProfileField from "./ProfileField";
|
||||||
import ProfileUpdateButton from "./ProfileUpdateButton";
|
import ProfileUpdateButton from "../buttons/ProfileUpdateButton";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
|
|||||||
@@ -1,11 +1,27 @@
|
|||||||
import React from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
import { List } from "../../../../ui/components/List";
|
import { List } from "../../../../ui/components/List";
|
||||||
import Tweet from "./Tweet";
|
import Tweet from "./Tweet";
|
||||||
import TweetSkeletonList from "./TweetSkeletonList";
|
import TweetSkeletonList from "./TweetSkeletonList";
|
||||||
|
|
||||||
|
const MINIMUM_LOAD_TIME = 700;
|
||||||
|
|
||||||
export function TweetList({ tweets }) {
|
export function TweetList({ tweets }) {
|
||||||
if (!tweets) return <TweetSkeletonList />;
|
const [minimumLoadPassed, setMimimumLoadPassed] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timeout = window.setTimeout(() => {
|
||||||
|
setMimimumLoadPassed(true);
|
||||||
|
}, MINIMUM_LOAD_TIME);
|
||||||
|
return () => window.clearTimeout(timeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
// we add a minimum (but short) load time here so that
|
||||||
|
// there isn't a quick flash of loading and immediately
|
||||||
|
// another flash to the tweets screen.
|
||||||
|
const hasLoaded = tweets && minimumLoadPassed;
|
||||||
|
|
||||||
|
if (!hasLoaded) return <TweetSkeletonList />;
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
{tweets.map((tweet) => (
|
{tweets.map((tweet) => (
|
||||||
|
|||||||
@@ -169,7 +169,8 @@ end)
|
|||||||
function updateTwitterProfile(identifier, data, cb)
|
function updateTwitterProfile(identifier, data, cb)
|
||||||
MySQL.Async.transaction({[[
|
MySQL.Async.transaction({[[
|
||||||
UPDATE npwd_twitter_profiles
|
UPDATE npwd_twitter_profiles
|
||||||
SET avatar_url = @avatar_url, profile_name = @profile_name, bio = @bio, location = @location, job = @job WHERE identifier = @identifier
|
SET avatar_url = @avatar_url, profile_name = @profile_name, bio = @bio, location = @location, job = @job
|
||||||
|
WHERE identifier = @identifier
|
||||||
]]},
|
]]},
|
||||||
{
|
{
|
||||||
identifier = identifier,
|
identifier = identifier,
|
||||||
|
|||||||
Reference in new issue
Block a user