@@ -30,11 +30,14 @@ public function __construct(
3030 $ this ->noteUtil = $ noteUtil ;
3131 }
3232
33- public function getAll (string $ userId , bool $ autoCreateNotesFolder = false ) : array {
33+ public function getAll (string $ userId , bool $ autoCreateNotesFolder = false , ? bool $ showHidden = null ) : array {
3434 $ customExtension = $ this ->getCustomExtension ($ userId );
3535 try {
3636 $ notesFolder = $ this ->getNotesFolder ($ userId , $ autoCreateNotesFolder );
37- $ data = self ::gatherNoteFiles ($ customExtension , $ notesFolder );
37+ if ($ showHidden === null ) {
38+ $ showHidden = $ this ->settings ->get ($ userId , 'showHidden ' );
39+ }
40+ $ data = self ::gatherNoteFiles ($ customExtension , $ notesFolder , $ showHidden );
3841 $ fileIds = array_keys ($ data ['files ' ]);
3942 // pre-load tags for all notes (performance improvement)
4043 $ this ->noteUtil ->getTagService ()->loadTags ($ fileIds );
@@ -66,7 +69,8 @@ public function countNotes(string $userId) : int {
6669 $ customExtension = $ this ->getCustomExtension ($ userId );
6770 try {
6871 $ notesFolder = $ this ->getNotesFolder ($ userId , false );
69- $ data = self ::gatherNoteFiles ($ customExtension , $ notesFolder );
72+ $ showHidden = $ this ->settings ->get ($ userId , 'showHidden ' );
73+ $ data = self ::gatherNoteFiles ($ customExtension , $ notesFolder , $ showHidden );
7074 return count ($ data ['files ' ]);
7175 } catch (NotesFolderException $ e ) {
7276 return 0 ;
@@ -168,6 +172,7 @@ private function getNotesFolder(string $userId, bool $create = true) : Folder {
168172 private static function gatherNoteFiles (
169173 string $ customExtension ,
170174 Folder $ folder ,
175+ bool $ showHidden ,
171176 string $ categoryPrefix = '' ,
172177 ) : array {
173178 $ data = [
@@ -176,10 +181,14 @@ private static function gatherNoteFiles(
176181 ];
177182 $ nodes = $ folder ->getDirectoryListing ();
178183 foreach ($ nodes as $ node ) {
184+ $ hidden = str_starts_with ($ node ->getName (), '. ' );
185+ if ($ hidden && !$ showHidden ) {
186+ continue ;
187+ }
179188 if ($ node ->getType () === FileInfo::TYPE_FOLDER && $ node instanceof Folder) {
180189 $ subCategory = $ categoryPrefix . $ node ->getName ();
181190 $ data ['categories ' ][] = $ subCategory ;
182- $ data_sub = self ::gatherNoteFiles ($ customExtension , $ node , $ subCategory . '/ ' );
191+ $ data_sub = self ::gatherNoteFiles ($ customExtension , $ node , $ showHidden , $ subCategory . '/ ' );
183192 $ data ['files ' ] = $ data ['files ' ] + $ data_sub ['files ' ];
184193 $ data ['categories ' ] = $ data ['categories ' ] + $ data_sub ['categories ' ];
185194 } elseif (self ::isNote ($ node , $ customExtension )) {
0 commit comments