@@ -711,7 +711,7 @@ export const bookmarksAppRouter = router({
711711 )
712712 . use ( ensureBookmarkOwnership )
713713 . mutation ( async ( { input, ctx } ) => {
714- return ctx . db . transaction ( async ( tx ) => {
714+ const res = await ctx . db . transaction ( async ( tx ) => {
715715 // Detaches
716716 const idsToRemove : string [ ] = [ ] ;
717717 if ( input . detach . length > 0 ) {
@@ -822,28 +822,32 @@ export const bookmarksAppRouter = router({
822822 ) ,
823823 ) ;
824824
825- await triggerRuleEngineOnEvent ( input . bookmarkId , [
826- ...idsToRemove . map ( ( t ) => ( {
825+ return {
826+ bookmarkId : input . bookmarkId ,
827+ attached : allIds ,
828+ detached : idsToRemove ,
829+ } ;
830+ } ) ;
831+
832+ await Promise . allSettled ( [
833+ triggerRuleEngineOnEvent ( input . bookmarkId , [
834+ ...res . detached . map ( ( t ) => ( {
827835 type : "tagRemoved" as const ,
828836 tagId : t ,
829837 } ) ) ,
830- ...allIds . map ( ( t ) => ( {
838+ ...res . attached . map ( ( t ) => ( {
831839 type : "tagAdded" as const ,
832840 tagId : t ,
833841 } ) ) ,
834- ] ) ;
835- await triggerSearchReindex ( input . bookmarkId , {
842+ ] ) ,
843+ triggerSearchReindex ( input . bookmarkId , {
836844 groupId : ctx . user . id ,
837- } ) ;
838- await triggerWebhook ( input . bookmarkId , "edited" , ctx . user . id , {
845+ } ) ,
846+ triggerWebhook ( input . bookmarkId , "edited" , ctx . user . id , {
839847 groupId : ctx . user . id ,
840- } ) ;
841- return {
842- bookmarkId : input . bookmarkId ,
843- attached : allIds ,
844- detached : idsToRemove ,
845- } ;
846- } ) ;
848+ } ) ,
849+ ] ) ;
850+ return res ;
847851 } ) ,
848852 getBrokenLinks : authedProcedure
849853 . output (
0 commit comments