Skip to content

Commit

Permalink
feat: user can edit slur words in hidden words for thread on uli-webs…
Browse files Browse the repository at this point in the history
…ite (#399)
  • Loading branch information
plon-Susk7 authored Oct 9, 2023
1 parent fd572f4 commit ba98983
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions uli-website/src/pages/hidden-words-for-thread.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useEffect, useRef } from "react";
import {
Box,
Heading,
Expand Down Expand Up @@ -36,11 +36,24 @@ const HiddenWordsForThread = () => {
});
const defaultOptions = selectOptions.map((option) => option.value);
const [choices, setChoices] = useState(defaultOptions);
const [text, setText] = useState("");
const textAreaRef = useRef(null);

useEffect(() => {
// Compute the text value based on choices and update the state
const computedText = choices
.map((choice) => options[choice].slurs.join(", "))
.join(", ");
setText(computedText);
}, [choices]);

function handleTextAreaChange(event) {
const currentValue = event.target.value;
setText(currentValue);
}

function clickCopyToClipboard() {
navigator.clipboard.writeText(
choices.map((choice) => options[choice].slurs.join(", ")).join(", ")
);
navigator.clipboard.writeText(text);
}

return (
Expand All @@ -51,7 +64,7 @@ const HiddenWordsForThread = () => {
<Paragraph fill>
Meta's Thread now allows you to filter out words that you don't want
to see on your feed. Uli's slur list can assist you in adding a list
of slurs in Indian languages. If you are being targetted or abused
of slurs in Indian languages. If you are being targeted or abused
on social media in Indian languages, consider adding these words to
your list of "hidden words" on Thread
</Paragraph>
Expand All @@ -77,10 +90,10 @@ const HiddenWordsForThread = () => {
<Box height={"1.2em"} />
<Box height={"50vh"}>
<TextArea
ref={textAreaRef}
fill
value={choices
.map((choice) => options[choice].slurs.join(", "))
.join(", ")}
value={text}
onChange={handleTextAreaChange}
/>
</Box>
<Heading level={2}>Contribute</Heading>
Expand Down

0 comments on commit ba98983

Please sign in to comment.