mirror of
https://github.com/pds-nest/nest.git
synced 2025-02-16 12:43:58 +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",
|
byZone: "area",
|
||||||
byHashtag: "hashtag",
|
byHashtag: "hashtag",
|
||||||
byUser: "utente",
|
byUser: "utente",
|
||||||
|
byRetweet: "retweet", // TODO: tradurre
|
||||||
|
isNotRetweetExplaination: "Nascondi i retweet.", // TODO: Tradurre
|
||||||
byHasImage: "immagine",
|
byHasImage: "immagine",
|
||||||
hasImageExplaination: "Mostra solo i tweet con immagine.",
|
hasImageExplaination: "Mostra solo i tweet con immagine.",
|
||||||
byTimePeriod: "arco di tempo",
|
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,
|
faHashtag,
|
||||||
faImage,
|
faImage,
|
||||||
faLocationArrow,
|
faLocationArrow,
|
||||||
faMapMarkerAlt,
|
faMapMarkerAlt, faRetweet,
|
||||||
} from "@fortawesome/free-solid-svg-icons"
|
} from "@fortawesome/free-solid-svg-icons"
|
||||||
import ButtonPicker from "./ButtonPicker"
|
import ButtonPicker from "./ButtonPicker"
|
||||||
import ContextRepositoryViewer from "../../contexts/ContextRepositoryViewer"
|
import ContextRepositoryViewer from "../../contexts/ContextRepositoryViewer"
|
||||||
|
@ -43,6 +43,12 @@ export default function PickerFilter({ ...props }) {
|
||||||
name={"user"}
|
name={"user"}
|
||||||
icon={faAt}
|
icon={faAt}
|
||||||
/>
|
/>
|
||||||
|
<ButtonPicker
|
||||||
|
currentTab={filterTab}
|
||||||
|
setTab={setFilterTab}
|
||||||
|
name={"retweet"}
|
||||||
|
icon={faRetweet}
|
||||||
|
/>
|
||||||
<ButtonPicker
|
<ButtonPicker
|
||||||
currentTab={filterTab}
|
currentTab={filterTab}
|
||||||
setTab={setFilterTab}
|
setTab={setFilterTab}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import SummaryBase from "../base/summary/SummaryBase"
|
import SummaryBase from "../base/summary/SummaryBase"
|
||||||
import SummaryLeft from "../base/summary/SummaryLeft"
|
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 SummaryText from "../base/summary/SummaryText"
|
||||||
import SummaryRight from "../base/summary/SummaryRight"
|
import SummaryRight from "../base/summary/SummaryRight"
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@ export default function SummaryTweet({ tweet, ...props }) {
|
||||||
if(tweet["image_url"]) {
|
if(tweet["image_url"]) {
|
||||||
icon = faImage
|
icon = faImage
|
||||||
}
|
}
|
||||||
|
else if(tweet["content"].startsWith("RT")) {
|
||||||
|
icon = faRetweet
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
icon = faComment
|
icon = faComment
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import useMapAreaState from "../../hooks/useMapAreaState"
|
||||||
import BoxFilterDatetime from "../interactive/BoxFilterDatetime"
|
import BoxFilterDatetime from "../interactive/BoxFilterDatetime"
|
||||||
import BoxFilterHasPlace from "../interactive/BoxFilterHasPlace"
|
import BoxFilterHasPlace from "../interactive/BoxFilterHasPlace"
|
||||||
import BoxFilterHasImage from "../interactive/BoxFilterHasImage"
|
import BoxFilterHasImage from "../interactive/BoxFilterHasImage"
|
||||||
|
import BoxFilterIsNotRetweet from "../interactive/BoxFilterIsNotRetweet"
|
||||||
|
|
||||||
|
|
||||||
export default function RepositoryViewer({ id, className, ...props }) {
|
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 === "contains" ? <BoxFilterContains className={Style.AddFilter}/> : null}
|
||||||
{filterTab === "hashtag" ? <BoxFilterHashtag className={Style.AddFilter}/> : null}
|
{filterTab === "hashtag" ? <BoxFilterHashtag className={Style.AddFilter}/> : null}
|
||||||
{filterTab === "user" ? <BoxFilterUser 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 === "image" ? <BoxFilterHasImage className={Style.AddFilter}/> : null}
|
||||||
{filterTab === "time" ? <BoxFilterDatetime className={Style.AddFilter}/> : null}
|
{filterTab === "time" ? <BoxFilterDatetime className={Style.AddFilter}/> : null}
|
||||||
{filterTab === "place" ? <BoxFilterHasPlace className={Style.AddFilter}/> : null}
|
{filterTab === "place" ? <BoxFilterHasPlace className={Style.AddFilter}/> : null}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
faHashtag,
|
faHashtag,
|
||||||
faImage,
|
faImage,
|
||||||
faLocationArrow,
|
faLocationArrow,
|
||||||
faMapMarkerAlt,
|
faMapMarkerAlt, faRetweet,
|
||||||
} from "@fortawesome/free-solid-svg-icons"
|
} from "@fortawesome/free-solid-svg-icons"
|
||||||
|
|
||||||
|
|
||||||
|
@ -241,4 +241,26 @@ export class FilterWithImage extends Filter {
|
||||||
children: "",
|
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…
Add table
Reference in a new issue