moved twitter skeleton to TweetList

This commit is contained in:
erik-sn committed 2020-10-03 10:59:52 -04:00
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 />,
2: <TwitterProfile />,
};
const MINIMUM_LOAD_TIME = 500;
const TWEETS_REFRESH_RATE = 50000000; // TODO move this to twitter config
const TWEETS_REFRESH_RATE = 15000; // TODO move this to twitter config
export const TwitterApp = () => {
const classes = useStyles();
const { modalVisible, setModalVisible } = useModal();
const [minimumLoadPassed, setMimimumLoadPassed] = useState(false);
const [activePage, setActivePage] = useState(0);
const { profile } = useProfile();
useEffect(() => {
Nui.send("phone:getOrCreateTwitterProfile", {});
Nui.send("phone:fetchTweets", {});
@@ -63,21 +61,9 @@ export const TwitterApp = () => {
return () => window.clearTimeout(timeout);
}, []);
useEffect(() => {
const timeout = window.setTimeout(() => {
setMimimumLoadPassed(true);
}, MINIMUM_LOAD_TIME);
return () => window.clearTimeout(timeout);
});
const openModal = () => setModalVisible(true);
const handlePageChange = (e, page) => setActivePage(page);
// 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;
const showTweetButton = activePage === 0;
return (
<AppWrapper id="twitter-app">
@@ -49,7 +49,7 @@ function TwitterSearch() {
inputRef={(input) => input && input.focus()}
/>
</div>
<TweetList tweets={tweets || []} />
{tweets && tweets.length > 0 && <TweetList tweets={tweets} />}
</div>
<SearchButton handleClick={handleSubmit} />
</>
@@ -6,7 +6,7 @@ import Nui from "../../../../os/nui-events/utils/Nui";
import { useProfile } from "../../hooks/useProfile";
import Avatar from "../Avatar";
import ProfileField from "./ProfileField";
import ProfileUpdateButton from "./ProfileUpdateButton";
import ProfileUpdateButton from "../buttons/ProfileUpdateButton";
const useStyles = makeStyles((theme) => ({
root: {
@@ -1,11 +1,27 @@
import React from "react";
import React, { useEffect, useState } from "react";
import { List } from "../../../../ui/components/List";
import Tweet from "./Tweet";
import TweetSkeletonList from "./TweetSkeletonList";
const MINIMUM_LOAD_TIME = 700;
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 (
<List>
{tweets.map((tweet) => (
+2 -1
View File
@@ -169,7 +169,8 @@ end)
function updateTwitterProfile(identifier, data, cb)
MySQL.Async.transaction({[[
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,