Skip to content

Commit

Permalink
fix: auto selection in Space's page
Browse files Browse the repository at this point in the history
  • Loading branch information
pnd280 committed Oct 20, 2024
1 parent f29bba7 commit 2085714
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Consider giving a star ⭐ on [Github](https://github.com/pnd280/complexity).

💖 Support the development via [Ko-fi](https://ko-fi.com/pnd280) or [Paypal](https://paypal.me/pnd280).

## v0.0.4.4

_Release date: 20st Oct, 2024_

- **FIX**: Fixed a bug where Space selector doesn't auto-select the space when in Space's page.

## v0.0.4.2

_Release date: 20th Oct, 2024_
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "complexity",
"displayName": "Complexity - Perplexity AI Supercharged",
"version": "0.0.4.2",
"version": "0.0.4.4",
"author": "pnd280",
"description": "⚡ Supercharge your Perplexity AI",
"type": "module",
Expand Down
20 changes: 10 additions & 10 deletions src/content-script/components/QueryBox/SpaceSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import useRouter from "@/content-script/hooks/useRouter";
import { useQueryBoxStore } from "@/content-script/session-store/query-box";
import { Popover } from "@/shared/components/Popover";
import UiUtils from "@/utils/UiUtils";
import { whereAmI } from "@/utils/utils";
import { parseUrl, whereAmI } from "@/utils/utils";

export default function SpaceSelector() {
const { url } = useRouter();
Expand All @@ -24,23 +24,23 @@ export default function SpaceSelector() {
}, [selectedSpaceUuid]);

useEffect(() => {
const autoSelect = () => {
if (whereAmI() !== "space") return;
if (whereAmI() !== "space" || spaces == null || spaces.length < 1) return;

const spaceSlug = window.location.pathname.split("/").pop();
const spaceSlug = parseUrl().pathname.split("/").pop();

const space = spaces?.find((x) => x.uuid === spaceSlug);
const space = spaces?.find(
(x) => x.slug === spaceSlug || x.uuid === spaceSlug,
);

if (space == null) return;
if (space == null) return;

setSelectedSpaceUuid(space.uuid);
};

autoSelect();
setSelectedSpaceUuid(space.uuid);
}, [url, spaces, setSelectedSpaceUuid]);

if (!isLoggedIn) return null;

if (whereAmI() === "space" && !selectedSpaceUuid) return null;

return (
<Popover portal={false}>
<SpaceSelectorPopoverTrigger
Expand Down
4 changes: 2 additions & 2 deletions src/content-script/components/ThreadExportButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import useToggleButtonText from "@/shared/hooks/useToggleButtonText";
import { toast } from "@/shared/toast";
import ThreadExport from "@/utils/ThreadExport";
import UiUtils from "@/utils/UiUtils";
import { isDomNode } from "@/utils/utils";
import { isDomNode, parseUrl } from "@/utils/utils";

const exportOptions = [
{
Expand All @@ -36,7 +36,7 @@ const exportOptions = [
] as const;

export default function ThreadExportButton() {
const slug = window.location.pathname.split("/").pop() || "";
const slug = parseUrl().pathname.split("/").pop() || "";
const { refetch, isFetching: isFetchingCurrentThreadInfo } =
useFetchThreadInfo({
slug,
Expand Down

0 comments on commit 2085714

Please sign in to comment.