preparing for experimental changes

This commit is contained in:
2022-01-27 15:13:11 -06:00
parent 5b1b6ed0ae
commit 5403267b9e
4 changed files with 19 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import React, { useState, useEffect } from "react";
import postsSlice, { fetchBySub, updatePosts, selectPosts } from "./postsSlice";
import { fetchBySub } from "./postsSlice";
import { selectAllSubs } from "../reddit/redditSlice";
import { useSelector, useDispatch } from "react-redux";
import { v4 } from "uuid";
@@ -8,6 +8,8 @@ import Post from "./Post";
export default function Feed() {
const [feed, setFeed] = useState(null);
const dispatch = useDispatch();
const subs = useSelector(selectAllSubs);
useEffect(() => {
let isActive = true;

View File

@@ -27,4 +27,8 @@ img, video {
display: inline-flex;
flex-direction: row;
justify-content: space-between;
}
.post-text {
font-size: 1.2rem;
}

View File

@@ -11,15 +11,23 @@ export default function Post({title,author,subreddit,ups,comments,time,key,media
} else {
return;
}
})
}, [setBody, selftext]);
const handleHover = () => {
setBody(selftext);
}
const handleMouseOut = () => {
setBody(selftext.substring(0,limit) + '...');
}
return (
<>
<div className="post-body">
<div className="post-body" onMouseOver={handleHover} onMouseOut={handleMouseOut}>
<a className="title" href={`https://reddit.com${permalink}`}>{title ? title : 'title'}</a>
{media ? <img alt={title} src={media} /> : ''}
{video ? <video controls type="video/mp4" src={video}></video> : ''}
<p>{body}</p>
<p className="post-text">{body}</p>
<div className="post-metadata">
<p className="user">{author ? 'u/' + author : 'u/username'}</p>
<p className="time-posted">{time ? time : ''}</p>

View File

@@ -7,7 +7,7 @@ export const fetchBySub = createAsyncThunk(
const myRequest = new Request(subreddit); // initializes request
let response = await fetch(myRequest);
let json = await response.json();
let postsArray = json.data.children; // unpacks individual post objects from the subreddit JSON file, as an array
let postsArray = json.data.children; // unpacks individual post objects from the subreddit JSON response, as an array
return postsArray;
} catch(e) {
console.log(e);