99namespace OCA \Bookmarks \Controller ;
1010
1111use OCA \Bookmarks \AugmentedTemplateResponse ;
12+ use OCA \Bookmarks \Db \BookmarkMapper ;
1213use OCA \Bookmarks \Db \Folder ;
1314use OCA \Bookmarks \Db \FolderMapper ;
1415use OCA \Bookmarks \Db \PublicFolder ;
3031use OCP \AppFramework \Http \NotFoundResponse ;
3132use OCP \AppFramework \Http \StreamResponse ;
3233use OCP \AppFramework \Http \Template \PublicTemplateResponse ;
34+ use OCP \DB \Exception ;
3335use OCP \EventDispatcher \IEventDispatcher ;
3436use OCP \IConfig ;
3537use OCP \IL10N ;
3638use OCP \IRequest ;
3739use OCP \IURLGenerator ;
3840use OCP \IUserManager ;
41+ use Psr \Log \LoggerInterface ;
3942
4043class WebViewController extends Controller {
4144 public function __construct (
@@ -51,11 +54,13 @@ public function __construct(
5154 private \OCA \Bookmarks \Controller \InternalFoldersController $ folderController ,
5255 private \OCA \Bookmarks \Controller \InternalBookmarkController $ bookmarkController ,
5356 private \OCA \Bookmarks \Controller \InternalTagsController $ tagsController ,
57+ private BookmarkMapper $ bookmarkMapper ,
5458 private UserSettingsService $ userSettingsService ,
5559 private SettingsService $ settings ,
5660 private IAppManager $ appManager ,
5761 private IConfig $ config ,
5862 private IEventDispatcher $ eventDispatcher ,
63+ private LoggerInterface $ logger ,
5964 ) {
6065 parent ::__construct ($ appName , $ request );
6166 }
@@ -89,14 +94,19 @@ public function index(): AugmentedTemplateResponse {
8994 $ res ->setContentSecurityPolicy ($ policy );
9095
9196 $ this ->initialState ->provideInitialState ($ this ->appName , 'folders ' , $ this ->folderController ->getFolders ()->getData ()['data ' ]);
92- $ this ->initialState ->provideInitialState ($ this ->appName , 'deletedFolders ' , $ this ->folderController ->getDeletedFolders ()->getData ()['data ' ]);
93- $ this ->initialState ->provideInitialState ($ this ->appName , 'archivedCount ' , $ this ->bookmarkController ->countArchived ()->getData ()['item ' ]);
94- $ this ->initialState ->provideInitialState ($ this ->appName , 'deletedCount ' , $ this ->bookmarkController ->countDeleted ()->getData ()['item ' ]);
95- $ this ->initialState ->provideInitialState ($ this ->appName , 'duplicatedCount ' , $ this ->bookmarkController ->countDuplicated ()->getData ()['item ' ]);
96- $ this ->initialState ->provideInitialState ($ this ->appName , 'unavailableCount ' , $ this ->bookmarkController ->countUnavailable ()->getData ()['item ' ]);
9797 $ this ->initialState ->provideInitialState ($ this ->appName , 'allCount ' , $ this ->bookmarkController ->countBookmarks (-1 )->getData ()['item ' ]);
98- $ this ->initialState ->provideInitialState ($ this ->appName , 'allClicksCount ' , $ this ->bookmarkController ->countAllClicks ()->getData ()['item ' ]);
99- $ this ->initialState ->provideInitialState ($ this ->appName , 'withClicksCount ' , $ this ->bookmarkController ->countWithClicks ()->getData ()['item ' ]);
98+
99+ try {
100+ $ this ->initialState ->provideInitialState ($ this ->appName , 'archivedCount ' , $ this ->bookmarkMapper ->countArchived ($ this ->userId ));
101+ $ this ->initialState ->provideInitialState ($ this ->appName , 'deletedCount ' , $ this ->bookmarkMapper ->countDeleted ($ this ->userId ));
102+ $ this ->initialState ->provideInitialState ($ this ->appName , 'duplicatedCount ' , $ this ->bookmarkMapper ->countDuplicated ($ this ->userId ));
103+ $ this ->initialState ->provideInitialState ($ this ->appName , 'unavailableCount ' , $ this ->bookmarkMapper ->countUnavailable ($ this ->userId ));
104+ $ this ->initialState ->provideInitialState ($ this ->appName , 'allClicksCount ' , $ this ->bookmarkMapper ->countAllClicks ($ this ->userId ));
105+ $ this ->initialState ->provideInitialState ($ this ->appName , 'withClicksCount ' , $ this ->bookmarkMapper ->countWithClicks ($ this ->userId ));
106+ } catch (Exception $ e ) {
107+ $ this ->logger ->error ($ e ->getMessage (), ['exception ' => $ e ]);
108+ }
109+
100110 $ this ->initialState ->provideInitialState ($ this ->appName , 'tags ' , $ this ->tagsController ->fullTags (true )->getData ());
101111 $ this ->initialState ->provideInitialState ($ this ->appName , 'contextChatInstalled ' , $ this ->appManager ->isEnabledForUser ('context_chat ' ));
102112 $ this ->initialState ->provideInitialState ($ this ->appName , 'appStoreEnabled ' , $ this ->config ->getSystemValueBool ('appstoreenabled ' , true ));
0 commit comments