Skip to content

Commit

Permalink
3Speak: fixed filtering in entry editing
Browse files Browse the repository at this point in the history
  • Loading branch information
dkildar committed Sep 19, 2023
1 parent 1d8b52f commit af243ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/common/components/video-gallery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface Props {
insertText: (before: string, after?: string) => any;
setVideoEncoderBeneficiary?: (video: any) => void;
toggleNsfwC?: () => void;
preFilter?: string;
setVideoMetadata?: (v: ThreeSpeakVideo) => void;
}

Expand All @@ -26,27 +25,24 @@ const VideoGallery = ({
insertText,
setVideoEncoderBeneficiary,
toggleNsfwC,
preFilter,
setVideoMetadata
}: Props) => {
const { activeUser } = useMappedStore();
const { isEditing } = useThreeSpeakManager();

const [label, setLabel] = useState("All");
const [filterStatus, setFilterStatus] = useState<ThreeSpeakVideo["status"] | "all">(
preFilter ?? "all"
isEditing ? "published" : "all"
);

const { data: items, isFetching, refresh } = useThreeSpeakVideo(filterStatus, showGallery);

useEffect(() => {
if (isEditing) {
setFilterStatus("published");
}
setFilterStatus(isEditing ? "published" : "all");
}, [isEditing]);

useEffect(() => {
setFilterStatus(preFilter ?? "all");
setFilterStatus(isEditing ? "published" : "all");
}, [activeUser]);

return (
Expand All @@ -63,7 +59,7 @@ const VideoGallery = ({
</Modal.Header>
<Modal.Body>
<div className="video-status-picker">
{!preFilter && !isEditing ? (
{!isEditing ? (
<DropDown
float="left"
label={label?.toUpperCase()}
Expand Down Expand Up @@ -122,7 +118,7 @@ const VideoGallery = ({
variant="link"
className="refresh-gallery p-0"
onClick={() => {
setFilterStatus(isEditing ? filterStatus : preFilter ?? "all");
setFilterStatus(isEditing ? filterStatus : "all");
setLabel(_t("video-gallery.all"));
refresh();
}}
Expand Down
3 changes: 3 additions & 0 deletions src/common/pages/submit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ export function Submit(props: PageProps & MatchProps) {
threeSpeakManager.setIsEditing(true);
} else if (editingEntry) {
setEditingEntry(null);
threeSpeakManager.setIsEditing(false);
} else {
threeSpeakManager.setIsEditing(false);
}
});

Expand Down

0 comments on commit af243ec

Please sign in to comment.