diff --git a/CHANGELOG.md b/CHANGELOG.md index d130bce7..c8387e1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +- Nothing worth mentioning yet. + ## [0.22.0] - 2024-03-24 ### Added diff --git a/playlet-lib/src/components/Screens/BookmarksScreen/BookmarksScreen.bs b/playlet-lib/src/components/Screens/BookmarksScreen/BookmarksScreen.bs index f35828cf..9d93707f 100644 --- a/playlet-lib/src/components/Screens/BookmarksScreen/BookmarksScreen.bs +++ b/playlet-lib/src/components/Screens/BookmarksScreen/BookmarksScreen.bs @@ -1,5 +1,6 @@ import "pkg:/components/ContextMenu/ContextMenuUtils.bs" import "pkg:/components/Navigation/Navigation.bs" +import "pkg:/components/Services/BookmarksService/BookmarksServiceUtils.bs" import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Types.bs" @@ -69,23 +70,7 @@ function OnBookmarksChange() as void end function function SetRowListContent(bookmarksContent 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 - - m.rowList.feeds = feeds + m.rowList.feeds = BookmarksServiceUtils.BookmarksContentToFeed(bookmarksContent) end function function OnkeyEvent(key as string, press as boolean) as boolean diff --git a/playlet-lib/src/components/Services/BookmarksService/BookmarksServiceUtils.bs b/playlet-lib/src/components/Services/BookmarksService/BookmarksServiceUtils.bs new file mode 100644 index 00000000..54d1baad --- /dev/null +++ b/playlet-lib/src/components/Services/BookmarksService/BookmarksServiceUtils.bs @@ -0,0 +1,23 @@ +namespace BookmarksServiceUtils + + function BookmarksContentToFeed(content as object) as object + bookmarkGroupNodes = content.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 namespace diff --git a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/BookmarksRouter.bs b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/BookmarksRouter.bs index 664c9a69..ebfb2fec 100644 --- a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/BookmarksRouter.bs +++ b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/BookmarksRouter.bs @@ -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