Bookmarks to feed refactor

This commit is contained in:
Brahim Hadriche committed 2024-03-24 23:23:23 -04:00
1 parent 45262c6394
commit 609c4622fd
4 files changed
+31 -41

No files matched your search

@@ -1,3 +1,4 @@
import "pkg:/components/Services/BookmarksService/BookmarksServiceUtils.bs"
import "pkg:/source/utils/RegistryUtils.bs"
namespace Http
@@ -33,35 +34,12 @@ namespace Http
function GetBookmarksFeeds(context as object) as boolean
response = context.response
feeds = m.BookmarksContentToFeeds(m.bookmarksService.content)
feeds = BookmarksServiceUtils.BookmarksContentToFeed(m.bookmarksService.content)
response.Json(feeds)
return true
end function
' TODO:P1 refactor to share code with Bookmarks screen
function BookmarksContentToFeeds(bookmarksContent as object) as object
bookmarkGroupNodes = bookmarksContent.getChildren(-1, 0)
feeds = []
for each bookmarkGroupNode in bookmarkGroupNodes
bookmarkNodes = bookmarkGroupNode.getChildren(-1, 0)
feedSources = []
for each bookmarkNode in bookmarkNodes
feedSources.push(bookmarkNode.feedSource)
end for
feeds.push({
"title": bookmarkGroupNode.title
"feedSources": feedSources
})
end for
return feeds
end function
end class
end namespace