mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 06:24:19 +00:00
✨ Add filter by retweet
This commit is contained in:
parent
957a6c892f
commit
c1c73caa2e
6 changed files with 94 additions and 4 deletions
|
@ -29,6 +29,8 @@ export default {
|
|||
byZone: "area",
|
||||
byHashtag: "hashtag",
|
||||
byUser: "utente",
|
||||
byRetweet: "retweet", // TODO: tradurre
|
||||
isNotRetweetExplaination: "Nascondi i retweet.", // TODO: Tradurre
|
||||
byHasImage: "immagine",
|
||||
hasImageExplaination: "Mostra solo i tweet con immagine.",
|
||||
byTimePeriod: "arco di tempo",
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
import React from "react"
|
||||
import BoxFull from "../base/BoxFull"
|
||||
import FormInline from "../base/FormInline"
|
||||
import useRepositoryViewer from "../../hooks/useRepositoryViewer"
|
||||
import useStrings from "../../hooks/useStrings"
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||
import { faPlus, faRetweet } from "@fortawesome/free-solid-svg-icons"
|
||||
import { FilterIsRetweet, FilterWithImage } from "../../objects/Filter"
|
||||
import ButtonIconOnly from "../base/ButtonIconOnly"
|
||||
|
||||
|
||||
/**
|
||||
* A {@link BoxFull} that allows the user to add a {@link FilterWithImage} to a RepositoryViewer.
|
||||
*
|
||||
* @param props - Additional props to pass to the box.
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
export default function BoxFilterIsNotRetweet({ ...props }) {
|
||||
const strings = useStrings()
|
||||
|
||||
const { appendFilter } = useRepositoryViewer()
|
||||
|
||||
const submit = () => {
|
||||
appendFilter(new FilterIsRetweet(true))
|
||||
}
|
||||
|
||||
// TODO: translate this
|
||||
|
||||
return (
|
||||
<BoxFull
|
||||
header={
|
||||
<span>
|
||||
{strings.searchBy}
|
||||
|
||||
<FontAwesomeIcon icon={faRetweet}/>
|
||||
|
||||
{strings.byRetweet}
|
||||
</span>
|
||||
}
|
||||
{...props}
|
||||
>
|
||||
<FormInline>
|
||||
<div style={{ "flexGrow": 1 }}>
|
||||
{strings.isNotRetweetExplaination}
|
||||
</div>
|
||||
<ButtonIconOnly
|
||||
icon={faPlus}
|
||||
color={"Green"}
|
||||
onClick={submit}
|
||||
/>
|
||||
</FormInline>
|
||||
</BoxFull>
|
||||
)
|
||||
}
|
|
@ -7,7 +7,7 @@ import {
|
|||
faHashtag,
|
||||
faImage,
|
||||
faLocationArrow,
|
||||
faMapMarkerAlt,
|
||||
faMapMarkerAlt, faRetweet,
|
||||
} from "@fortawesome/free-solid-svg-icons"
|
||||
import ButtonPicker from "./ButtonPicker"
|
||||
import ContextRepositoryViewer from "../../contexts/ContextRepositoryViewer"
|
||||
|
@ -43,6 +43,12 @@ export default function PickerFilter({ ...props }) {
|
|||
name={"user"}
|
||||
icon={faAt}
|
||||
/>
|
||||
<ButtonPicker
|
||||
currentTab={filterTab}
|
||||
setTab={setFilterTab}
|
||||
name={"retweet"}
|
||||
icon={faRetweet}
|
||||
/>
|
||||
<ButtonPicker
|
||||
currentTab={filterTab}
|
||||
setTab={setFilterTab}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React from "react"
|
||||
import SummaryBase from "../base/summary/SummaryBase"
|
||||
import SummaryLeft from "../base/summary/SummaryLeft"
|
||||
import { faComment, faImage } from "@fortawesome/free-solid-svg-icons"
|
||||
import { faComment, faImage, faRetweet } from "@fortawesome/free-solid-svg-icons"
|
||||
import SummaryText from "../base/summary/SummaryText"
|
||||
import SummaryRight from "../base/summary/SummaryRight"
|
||||
|
||||
|
@ -19,6 +19,9 @@ export default function SummaryTweet({ tweet, ...props }) {
|
|||
if(tweet["image_url"]) {
|
||||
icon = faImage
|
||||
}
|
||||
else if(tweet["content"].startsWith("RT")) {
|
||||
icon = faRetweet
|
||||
}
|
||||
else {
|
||||
icon = faComment
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import useMapAreaState from "../../hooks/useMapAreaState"
|
|||
import BoxFilterDatetime from "../interactive/BoxFilterDatetime"
|
||||
import BoxFilterHasPlace from "../interactive/BoxFilterHasPlace"
|
||||
import BoxFilterHasImage from "../interactive/BoxFilterHasImage"
|
||||
import BoxFilterIsNotRetweet from "../interactive/BoxFilterIsNotRetweet"
|
||||
|
||||
|
||||
export default function RepositoryViewer({ id, className, ...props }) {
|
||||
|
@ -124,6 +125,7 @@ export default function RepositoryViewer({ id, className, ...props }) {
|
|||
{filterTab === "contains" ? <BoxFilterContains className={Style.AddFilter}/> : null}
|
||||
{filterTab === "hashtag" ? <BoxFilterHashtag className={Style.AddFilter}/> : null}
|
||||
{filterTab === "user" ? <BoxFilterUser className={Style.AddFilter}/> : null}
|
||||
{filterTab === "retweet" ? <BoxFilterIsNotRetweet className={Style.AddFilter}/> : null}
|
||||
{filterTab === "image" ? <BoxFilterHasImage className={Style.AddFilter}/> : null}
|
||||
{filterTab === "time" ? <BoxFilterDatetime className={Style.AddFilter}/> : null}
|
||||
{filterTab === "place" ? <BoxFilterHasPlace className={Style.AddFilter}/> : null}
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
faHashtag,
|
||||
faImage,
|
||||
faLocationArrow,
|
||||
faMapMarkerAlt,
|
||||
faMapMarkerAlt, faRetweet,
|
||||
} from "@fortawesome/free-solid-svg-icons"
|
||||
|
||||
|
||||
|
@ -241,4 +241,26 @@ export class FilterWithImage extends Filter {
|
|||
children: "",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a tweet is a retweet.
|
||||
*/
|
||||
export class FilterIsRetweet extends Filter {
|
||||
constructor(negate = false) {
|
||||
super(negate)
|
||||
}
|
||||
|
||||
check(tweet) {
|
||||
return tweet.content.startsWith("RT")
|
||||
}
|
||||
|
||||
display() {
|
||||
return {
|
||||
color: "Green",
|
||||
icon: faRetweet,
|
||||
children: "",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue