@ -4,13 +4,13 @@ import { WebSocketService, UserService } from '../services';
import { Post , CreatePostLikeForm , PostForm as PostFormI , SavePostForm , CommunityUser , UserView } from '../interfaces' ;
import { Post , CreatePostLikeForm , PostForm as PostFormI , SavePostForm , CommunityUser , UserView } from '../interfaces' ;
import { MomentTime } from './moment-time' ;
import { MomentTime } from './moment-time' ;
import { PostForm } from './post-form' ;
import { PostForm } from './post-form' ;
import { mdToHtml , canMod , isMod } from '../utils' ;
import { mdToHtml , canMod , isMod , isImage } from '../utils' ;
interface PostListingState {
interface PostListingState {
showEdit : boolean ;
showEdit : boolean ;
showRemoveDialog : boolean ;
showRemoveDialog : boolean ;
removeReason : string ;
removeReason : string ;
i fram eExpanded: boolean ;
i mag eExpanded: boolean ;
}
}
interface PostListingProps {
interface PostListingProps {
@ -29,7 +29,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
showEdit : false ,
showEdit : false ,
showRemoveDialog : false ,
showRemoveDialog : false ,
removeReason : null ,
removeReason : null ,
i fram eExpanded: false
i mag eExpanded: false
}
}
constructor ( props : any , context : any ) {
constructor ( props : any , context : any ) {
@ -78,15 +78,19 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
}
}
< / h5 >
< / h5 >
< small > < a className = "ml-2 text-muted font-italic" href = { post . url } title = { post . url } > { ( new URL ( post . url ) ) . hostname } < / a > < / small >
< small > < a className = "ml-2 text-muted font-italic" href = { post . url } title = { post . url } > { ( new URL ( post . url ) ) . hostname } < / a > < / small >
{ ! this . state . iframeExpanded
{ isImage ( post . url ) &&
? < span class = "badge badge-light pointer ml-2 text-muted small" title = "Expand here" onClick = { linkEvent ( this , this . handleIframeExpandClick ) } > + < / span >
< >
:
{ ! this . state . imageExpanded
< span >
? < span class = "badge badge-light pointer ml-2 text-muted small" title = "Expand here" onClick = { linkEvent ( this , this . handleImageExpandClick ) } > + < / span >
< span class = "pointer ml-2 badge badge-light text-muted small" onClick = { linkEvent ( this , this . handleIframeExpandClick ) } > - < / span >
:
< div class = "embed-responsive embed-responsive-1by1" >
< span >
< iframe scrolling = "yes" class = "embed-responsive-item" src = { post . url } > < / iframe >
< span class = "pointer ml-2 badge badge-light text-muted small" onClick = { linkEvent ( this , this . handleImageExpandClick ) } > - < / span >
< / div >
< div >
< / span >
< img class = "img-fluid" src = { post . url } / >
< / div >
< / span >
}
< / >
}
}
< / div >
< / div >
: < h5 className = "mb-0" > < Link className = "text-white" to = { ` /post/ ${ post . id } ` } > { post . name } < / Link >
: < h5 className = "mb-0" > < Link className = "text-white" to = { ` /post/ ${ post . id } ` } > { post . name } < / Link >
@ -292,8 +296,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
WebSocketService . Instance . editPost ( form ) ;
WebSocketService . Instance . editPost ( form ) ;
}
}
handleI fram eExpandClick( i : PostListing ) {
handleI mag eExpandClick( i : PostListing ) {
i . state . i frameExpanded = ! i . state . ifram eExpanded;
i . state . i mageExpanded = ! i . state . imag eExpanded;
i . setState ( i . state ) ;
i . setState ( i . state ) ;
}
}
}
}