From 1c155f6cbe56027656c917ed393d8459738a0d58 Mon Sep 17 00:00:00 2001
From: rahulramesha <71900764+rahulramesha@users.noreply.github.com>
Date: Thu, 25 Jul 2024 15:17:20 +0530
Subject: [PATCH] fix view layout in space app (#5225)
---
space/app/views/[anchor]/layout.tsx | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/space/app/views/[anchor]/layout.tsx b/space/app/views/[anchor]/layout.tsx
index 81d0c992d..cf7643bb6 100644
--- a/space/app/views/[anchor]/layout.tsx
+++ b/space/app/views/[anchor]/layout.tsx
@@ -5,6 +5,7 @@ import Image from "next/image";
import useSWR from "swr";
// components
import { LogoSpinner } from "@/components/common";
+import { SomethingWentWrongError } from "@/components/issues/issue-layouts/error";
// hooks
import { usePublish, usePublishList } from "@/hooks/store";
// Plane web
@@ -28,25 +29,22 @@ const IssuesLayout = observer((props: Props) => {
const { fetchPublishSettings } = usePublishList();
const { viewData, fetchViewDetails } = useView();
const publishSettings = usePublish(anchor);
- // fetch publish settings
- useSWR(
- anchor ? `PUBLISH_SETTINGS_${anchor}` : null,
+
+ // fetch publish settings && view details
+ const { error } = useSWR(
+ anchor ? `PUBLISHED_VIEW_SETTINGS_${anchor}` : null,
anchor
? async () => {
- await fetchPublishSettings(anchor);
- }
- : null
- );
- // fetch view data
- useSWR(
- anchor ? `VIEW_DETAILS_${anchor}` : null,
- anchor
- ? async () => {
- await fetchViewDetails(anchor);
+ const promises = [];
+ promises.push(fetchPublishSettings(anchor));
+ promises.push(fetchViewDetails(anchor));
+ await Promise.all(promises);
}
: null
);
+ if (error) return ;
+
if (!publishSettings || !viewData) return ;
return (