11"use client" ;
22
3- import { FC , useEffect , useState , useMemo } from "react" ;
3+ import { FC , useEffect , useState , useMemo , useCallback } from "react" ;
44import { observer } from "mobx-react" ;
55import { usePathname } from "next/navigation" ;
66// plane types
@@ -21,12 +21,11 @@ import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/u
2121interface IIssuePeekOverview {
2222 embedIssue ?: boolean ;
2323 embedRemoveCurrentNotification ?: ( ) => void ;
24- is_archived ?: boolean ;
2524 is_draft ?: boolean ;
2625}
2726
2827export const IssuePeekOverview : FC < IIssuePeekOverview > = observer ( ( props ) => {
29- const { embedIssue = false , embedRemoveCurrentNotification, is_archived = false , is_draft = false } = props ;
28+ const { embedIssue = false , embedRemoveCurrentNotification, is_draft = false } = props ;
3029 // router
3130 const pathname = usePathname ( ) ;
3231 // store hook
@@ -47,26 +46,20 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
4746 // state
4847 const [ error , setError ] = useState ( false ) ;
4948
50- const removeRoutePeekId = ( ) => {
49+ const removeRoutePeekId = useCallback ( ( ) => {
5150 setPeekIssue ( undefined ) ;
5251 if ( embedIssue ) embedRemoveCurrentNotification ?.( ) ;
53- } ;
52+ } , [ embedIssue , embedRemoveCurrentNotification , setPeekIssue ] ) ;
5453
5554 const issueOperations : TIssueOperations = useMemo (
5655 ( ) => ( {
5756 fetch : async ( workspaceSlug : string , projectId : string , issueId : string ) => {
5857 try {
5958 setError ( false ) ;
60- await fetchIssue (
61- workspaceSlug ,
62- projectId ,
63- issueId ,
64- is_archived ? "ARCHIVED" : is_draft ? "DRAFT" : "DEFAULT"
65- ) ;
66- setError ( false ) ;
59+ await fetchIssue ( workspaceSlug , projectId , issueId , is_draft ? "DRAFT" : "DEFAULT" ) ;
6760 } catch ( error ) {
6861 setError ( true ) ;
69- console . error ( "Error fetching the parent issue" ) ;
62+ console . error ( "Error fetching the parent issue" , error ) ;
7063 }
7164 } ,
7265 update : async ( workspaceSlug : string , projectId : string , issueId : string , data : Partial < TIssue > ) => {
@@ -109,7 +102,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
109102 } ) ;
110103 removeRoutePeekId ( ) ;
111104 } ) ;
112- } catch ( error ) {
105+ } catch {
113106 setToast ( {
114107 title : "Error!" ,
115108 type : TOAST_TYPE . ERROR ,
@@ -124,13 +117,14 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
124117 } ,
125118 archive : async ( workspaceSlug : string , projectId : string , issueId : string ) => {
126119 try {
127- issues ?. archiveIssue && ( await issues . archiveIssue ( workspaceSlug , projectId , issueId ) ) ;
120+ if ( ! issues ?. archiveIssue ) return ;
121+ await issues . archiveIssue ( workspaceSlug , projectId , issueId ) ;
128122 captureIssueEvent ( {
129123 eventName : ISSUE_ARCHIVED ,
130124 payload : { id : issueId , state : "SUCCESS" , element : "Issue peek-overview" } ,
131125 path : pathname ,
132126 } ) ;
133- } catch ( error ) {
127+ } catch {
134128 captureIssueEvent ( {
135129 eventName : ISSUE_ARCHIVED ,
136130 payload : { id : issueId , state : "FAILED" , element : "Issue peek-overview" } ,
@@ -151,7 +145,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
151145 payload : { id : issueId , state : "SUCCESS" , element : "Issue peek-overview" } ,
152146 path : pathname ,
153147 } ) ;
154- } catch ( error ) {
148+ } catch {
155149 setToast ( {
156150 type : TOAST_TYPE . ERROR ,
157151 title : "Error!" ,
@@ -177,7 +171,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
177171 } ,
178172 path : pathname ,
179173 } ) ;
180- } catch ( error ) {
174+ } catch {
181175 setToast ( {
182176 type : TOAST_TYPE . ERROR ,
183177 title : "Error!" ,
@@ -206,7 +200,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
206200 } ,
207201 path : pathname ,
208202 } ) ;
209- } catch ( error ) {
203+ } catch {
210204 setToast ( {
211205 type : TOAST_TYPE . ERROR ,
212206 title : "Error!" ,
@@ -248,7 +242,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
248242 } ,
249243 path : pathname ,
250244 } ) ;
251- } catch ( error ) {
245+ } catch {
252246 captureIssueEvent ( {
253247 eventName : ISSUE_UPDATED ,
254248 payload : { state : "FAILED" , element : "Issue peek-overview" } ,
@@ -311,7 +305,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
311305 } ,
312306 path : pathname ,
313307 } ) ;
314- } catch ( error ) {
308+ } catch {
315309 captureIssueEvent ( {
316310 eventName : ISSUE_UPDATED ,
317311 payload : { id : issueId , state : "FAILED" , element : "Issue peek-overview" } ,
@@ -324,7 +318,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
324318 }
325319 } ,
326320 } ) ,
327- [ is_archived , is_draft , fetchIssue , issues , restoreIssue , captureIssueEvent , pathname ]
321+ [ fetchIssue , is_draft , issues , fetchActivities , captureIssueEvent , pathname , removeRoutePeekId , restoreIssue ]
328322 ) ;
329323
330324 useEffect ( ( ) => {
@@ -350,7 +344,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
350344 issueId = { peekIssue . issueId }
351345 isLoading = { getIsFetchingIssueDetails ( peekIssue . issueId ) }
352346 isError = { error }
353- is_archived = { is_archived }
347+ is_archived = { ! ! peekIssue . isArchived }
354348 disabled = { ! isEditable }
355349 embedIssue = { embedIssue }
356350 embedRemoveCurrentNotification = { embedRemoveCurrentNotification }
0 commit comments