Bookmarks to feed refactor
This commit is contained in:
1 parent
45262c6394
commit
609c4622fd
4 files changed
+31
-41
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user