Skip to content

Commit

Permalink
lots of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMouritzen committed Sep 20, 2021
1 parent f8952fb commit 162555a
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 28 deletions.
89 changes: 89 additions & 0 deletions app/components/Episode/Comments/EpisodeCommentList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React, { useEffect, useState } from 'react';

import DOMPurify from 'dompurify';

import ActivityPub from 'podfriend-approot/library/ActivityPub/ActivityPub.js';
import styles from './EpisodeCommentList.scss';


const EpisodeComment = ({ from, content }) => {
const [commentText,setCommentText] = useState('Loading comment.');

useEffect(() => {
setCommentText(DOMPurify.sanitize(content,{
ALLOWED_TAGS: [] // we used to allow 'i','em', but it doesn't work on mobile. I'm not sure I can see a good reason to have them.
}));
},[]);

return (
<div className={styles.comment}>
<img src={from.avatar} className={styles.avatar} />
<div className={styles.commentContent}>
<div className={styles.username}>{from.username}</div>
<div className={styles.commentText}>
{commentText}
</div>
</div>
</div>
);
};
const EpisodeCommentList = ({ commentURL }) => {
const [commentInfo,setCommentInfo] = useState(false);
const [comments,setComments] = useState([]);

useEffect(() => {
const retrieveCommentInformation = (commentURL) => {
console.log('RSS has Comment URL: ');
console.log(commentURL);

ActivityPub.getCommentInformation(commentURL.uri)
.then((commentResponse) => {
setCommentInfo(commentResponse);
})
.catch((error) => {
console.log('error getting comments: ');
console.log(error);
});
};

if (commentURL) {
retrieveCommentInformation(commentURL);
}
},[commentURL]);

useEffect(() => {
if (commentInfo) {
const retrieveComments = () => {
console.log('retrieveComments()');
return ActivityPub.getComments(commentInfo,0)
.then((comments) => {
console.log('comments');
console.log(comments);
setComments(comments);
});
};
retrieveComments();
}
},[commentInfo]);


return (
<div className={styles.commentList}>
{ Array.isArray(comments) === false &&
<div>
No comments yet for this episode.
</div>
}
{ Array.isArray(comments) && comments.map((comment,index) => {
console.log('comment: ');
console.log(comment);
return <EpisodeComment key={index} from={comment.from} content={comment.content} />;
})}
<div className={styles.writeCommentContainer}>
<textarea className={styles.writeComment} placeholder="How do you feel about this episode?"></textarea>
<button>Post comment</button>
</div>
</div>
);
};
export default EpisodeCommentList;
50 changes: 50 additions & 0 deletions app/components/Episode/Comments/EpisodeCommentList.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.commentList {
min-height: 100vh;

.writeCommentContainer {
margin-top: 30px;

textarea {
display: block;
background-color: rgba(0,0,0,0.1);
border: 0px;
width: 100%;
height: 150px;
padding: 10px;
font-size: 16px;

margin-bottom: 10px;

border-radius: 5px;

outline: 1px solid rgba(0,0,0,0);

transition: 0.2s all;
}
textarea:focus {
outline: 1px solid rgba(0,0,0,0.3);
}
button {
width: 100%;
}
}
}
.comment {
display: flex;

.avatar {
width: 30px;
height: 30px;
border-radius: 50%;
margin-right: 10px;
}
.username {
font-weight: bold;
margin-bottom: 5px;
}
.commentContent {
.commentText {

}
}
}
4 changes: 4 additions & 0 deletions app/components/Player/Player.scss
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@
background-color: #FFFFFF;
flex-direction: column;
}
.segmentCommentsList {
background-color: #FFFFFF;
flex-direction: column;
}
.segmentVisible {
opacity: 1;
}
Expand Down
78 changes: 56 additions & 22 deletions app/components/Player/PlayerUI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ import EpisodeList from 'podfriend-approot/components/Podcast/EpisodeList.jsx';
import Wave from 'podfriend-approot/images/design/blue-wave-1.svg';
import EpisodeChapterList from 'podfriend-approot/components/Episode/Chapters/EpisodeChapterList.jsx';

import EpisodeCommentList from 'podfriend-approot/components/Episode/Comments/EpisodeCommentList.jsx';

const Value4ValueModal = lazy(() => import('podfriend-approot/components/Wallet/Value4ValueModal.jsx'));
// import Value4ValueModal from 'podfriend-approot/components/Wallet/Value4ValueModal.jsx';

Expand Down Expand Up @@ -98,6 +100,8 @@ const PlayerUI = ({ audioController, activePodcast, activeEpisode, title, progre
const [error,setError] = useState(false);
const [errorText,setErrorText] = useState(false);

const [supportsComments,setSupportsComments] = useState(false);

const [segmentVisible,setSegmentVisible] = useState('playing');

const [rssFeed,setRSSFeed] = useState(false);
Expand All @@ -118,6 +122,15 @@ const PlayerUI = ({ audioController, activePodcast, activeEpisode, title, progre
onAudioElementReady();
},[audioElement]);

useEffect(() => {
if (rssFeed && rssFeed.supportsComments()) {
setSupportsComments(true);
}
else {
setSupportsComments(false);
}
},[rssFeed]);

const onTranscriptSearchClose = () => {
setTranscriptSearchOpen(false);
};
Expand Down Expand Up @@ -445,6 +458,7 @@ const PlayerUI = ({ audioController, activePodcast, activeEpisode, title, progre
else {
setChaptersLoading(false);
}

if (rssFeedCurrentEpisode.transcript) {
// console.log('Episode has transcript');
var useTranscript = rssFeedCurrentEpisode.transcript;
Expand All @@ -469,6 +483,7 @@ const PlayerUI = ({ audioController, activePodcast, activeEpisode, title, progre
setRSSFeed(false);
setRssFeedCurrentEpisode(false);
setDescription('');
setShowNotes(false);

const fetchEpisodeData = async() => {
var podcastFeed = new PodcastFeed(activePodcast.feedUrl);
Expand Down Expand Up @@ -574,28 +589,6 @@ const PlayerUI = ({ audioController, activePodcast, activeEpisode, title, progre
}
<div className={styles.openPlayerBackground} style={{ display: (fullPlayerOpen ? 'block' : 'none') }} onClick={() => { dispatch(showFullPlayer(false)); }} />
<DraggablePane onOpen={showEpisodePane} onHide={hideEpisodePane} open={fullPlayerOpen} className={(fullPlayerOpen ? styles.episodeOpen : styles.episodeClosed) + ' ' + styles.player + (playing ? ' ' + styles.playing : ' ' + styles.notPlaying)} style={{ display: hasEpisode ? 'flex' : 'flex' }}>

{ fullPlayerOpen && chapters !== false &&
<div style={{ width: '100%', paddingLeft: 20, paddingRight: 20, maxWidth: 440 }}>
<IonSegment value={segmentVisible} onIonChange={(e) => { setSegmentVisible(e.detail.value); console.log(e.detail.value); }} onClick={(event) => { event.preventDefault(); event.stopPropagation(); }}>
<IonSegmentButton value="playing">
<IonLabel>
Playing
</IonLabel>
</IonSegmentButton>
{ chapters !== false &&
<IonSegmentButton value="chapterList">
<IonLabel>Chapters</IonLabel>
</IonSegmentButton>
}
{/*
<IonSegmentButton value="social">
<IonLabel>Social</IonLabel>
</IonSegmentButton>
*/}
</IonSegment>
</div>
}
<div className={styles.segment + ' ' + styles.segmentPlaying + ' ' + (segmentVisible === 'playing' || !fullPlayerOpen ? styles.segmentVisible : styles.segmentHidden) }>
<div
className={styles.playingPreview}
Expand Down Expand Up @@ -737,6 +730,7 @@ const PlayerUI = ({ audioController, activePodcast, activeEpisode, title, progre
}
{ fullPlayerOpen &&
<OpenPlayerUI
rssFeed={rssFeed}
description={description}
showNotes={showNotes}
activePodcast={activePodcast}
Expand All @@ -756,6 +750,32 @@ const PlayerUI = ({ audioController, activePodcast, activeEpisode, title, progre

}
</div>
{ fullPlayerOpen && (chapters !== false || supportsComments !== false) &&
<div style={{ width: '100%', paddingLeft: 20, paddingRight: 20, maxWidth: 440 }}>
<IonSegment value={segmentVisible} onIonChange={(e) => { setSegmentVisible(e.detail.value); console.log(e.detail.value); }} onClick={(event) => { event.preventDefault(); event.stopPropagation(); }}>
<IonSegmentButton value="playing">
<IonLabel>
Playing
</IonLabel>
</IonSegmentButton>
{ chapters !== false &&
<IonSegmentButton value="chapterList">
<IonLabel>Chapters</IonLabel>
</IonSegmentButton>
}
{ supportsComments !== false &&
<IonSegmentButton value="commentList">
<IonLabel>Comments</IonLabel>
</IonSegmentButton>
}
{/*
<IonSegmentButton value="social">
<IonLabel>Social</IonLabel>
</IonSegmentButton>
*/}
</IonSegment>
</div>
}
{ fullPlayerOpen && false &&
<div className={styles.segment + ' ' + styles.segmentEpisodeList + ' ' + ((segmentVisible === 'episodeList' && fullPlayerOpen) ? styles.segmentVisible : styles.segmentHidden) }>
<PlayerEpisodeList episodes={activePodcast.episodes} activeEpisode={activeEpisode} />
Expand Down Expand Up @@ -791,6 +811,20 @@ const PlayerUI = ({ audioController, activePodcast, activeEpisode, title, progre
</div>
</div>
}
{ fullPlayerOpen && supportsComments !== false &&
<div className={styles.segment + ' ' + styles.segmentCommentsList + ' ' + ((segmentVisible === 'commentList' && fullPlayerOpen) ? styles.segmentVisible : styles.segmentHidden) }>
<div style={{ height: '80px', bottom: '1px', overflow: 'hidden' }} >
<svg viewBox="0 0 500 150" preserveAspectRatio="none" style={{ height: '150px', width: '100%', backgroundColor: '#0176e5' }}>
<path d="M-0.90,34.83 C167.27,-67.79 269.41,126.60 500.78,16.08 L503.61,86.15 L-0.33,87.14 Z" style={{ stroke: 'none', fill: '#FFFFFF' }} />
</svg>
</div>
<div style={{ width: '100%', maxWidth: 600, marginLeft: 'auto', marginRight: 'auto' }}>
<div style={{ paddingLeft: 10, paddingRight: 10 }}>
<EpisodeCommentList rootType='episode' commentURL={rssFeedCurrentEpisode.commentURL} />
</div>
</div>
</div>
}
</DraggablePane>
{ fullPlayerOpen === false &&
<div className={styles.bottomProgressBar}>
Expand Down
1 change: 1 addition & 0 deletions app/components/Player/ProgressBarSlider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const ProgressBarSlider = ({progress,duration,fullPlayerOpen,onProgressSliderCha
style={{
height: '6px',
width: '100%',
borderRadius: '3px',
alignSelf: 'center',
background: getTrackBackground({
values: [sliderValue],
Expand Down
1 change: 1 addition & 0 deletions app/components/Player/VolumeSlider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const VolumeSlider = ({ audioElement }) => {
style={{
height: '6px',
width: '100%',
borderRadius: '3px',
alignSelf: 'center',
background: getTrackBackground({
values: [volumeLevel],
Expand Down
2 changes: 1 addition & 1 deletion app/components/PodCastClient.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class PodcastClient extends Component {
<PageError>
<Suspense fallback={<div>Loading...</div>}>
<Switch>
<Route exact path="/" render={(props) => { return (<Welcome {...props} />); }} />
<Route exact path="/" render={(props) => { return (<FeedPage {...props} />); }} />
<Route path="/search/author/:author/:authorId?" render={(props) => { return (<SearchPane searchType="author" {...props} UI={SearchPaneUI} />); }} />
<Route path="/search/:query?" render={(props) => { return (<SearchPane searchType="podcast" {...props} UI={SearchPaneUI} />); }} />
<Route path="/podfrndr/" render={(props) => { return (<SwipeExplorer {...props} />); }} />
Expand Down
Loading

0 comments on commit 162555a

Please sign in to comment.