@@ -108,13 +108,16 @@ public function edit(ProcessRequestToken $task, string $preview = '')
108108 {
109109 $ task = $ task ->loadTokenInstance ();
110110 $ dataManager = new DataManager ();
111- $ userHasComments = Comment::where ('commentable_type ' , ProcessRequestToken::class)
112- ->where ('commentable_id ' , $ task ->id )
113- ->where ('body ' , 'like ' , '%{{ ' . \Auth::user ()->id . '}}% ' )
114- ->count () > 0 ;
115111
116- if (!\Auth::user ()->can ('update ' , $ task ) && !$ userHasComments ) {
117- $ this ->authorize ('update ' , $ task );
112+ if (!\Auth::user ()->can ('update ' , $ task )) {
113+ $ userHasComments = Comment::where ('commentable_type ' , ProcessRequestToken::class)
114+ ->where ('commentable_id ' , $ task ->id )
115+ ->where ('body ' , 'like ' , '%{{ ' . \Auth::user ()->id . '}}% ' )
116+ ->count () > 0 ;
117+
118+ if (!$ userHasComments ) {
119+ $ this ->authorize ('update ' , $ task );
120+ }
118121 }
119122
120123 //Mark notification as read
@@ -178,7 +181,9 @@ public function edit(ProcessRequestToken $task, string $preview = '')
178181 ]);
179182 }
180183
181- UserResourceView::setViewed (Auth::user (), $ task );
184+ dispatch (function () use ($ task ) {
185+ UserResourceView::setViewed (Auth::user (), $ task );
186+ })->afterResponse ();
182187 $ currentUser = Auth::user ()->only ([
183188 'id ' ,
184189 'username ' ,
@@ -189,7 +194,8 @@ public function edit(ProcessRequestToken $task, string $preview = '')
189194 'timezone ' ,
190195 'datetime_format ' ,
191196 ]);
192- $ userConfiguration = (new UserConfigurationController ())->index ();
197+ //$userConfiguration = (new UserConfigurationController())->index();
198+ $ userConfiguration = app (UserConfigurationController::class)->index ();
193199 $ hitlEnabled = config ('smart-extract.hitl_enabled ' , false ) && $ isSmartExtractTask ;
194200
195201 // Build the iframe source
@@ -209,9 +215,11 @@ public function edit(ProcessRequestToken $task, string $preview = '')
209215 $ iframeSrc = $ dashboardUrl . '? ' . $ queryParams ;
210216 }
211217 }
218+ $ canUpdateTask = Auth::user ()->can ('update ' , $ task );
212219
213220 return view ('tasks.edit ' , [
214221 'task ' => $ task ,
222+ 'canUpdateTask ' => $ canUpdateTask ,
215223 'dueLabels ' => self ::$ dueLabels ,
216224 'manager ' => $ manager ,
217225 'submitUrl ' => $ submitUrl ,
0 commit comments