Customize home screen (#250)
* Customize home screen * remove logs * Lint fix * move func * Fix for checklist * Fix save state * open api * Fix spec * Changelog * Add TODO * Button size --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
e7324495fe
commit
fd7bdde733
21 files changed
+638
-16
No files matched your search
@@ -5,6 +5,12 @@ 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.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A home screen editor allowing to enable/disable feeds, and change their order.
|
||||||
|
|
||||||
## [0.18.1] - 2024-01-02
|
## [0.18.1] - 2024-01-02
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ paths:
|
|||||||
properties:
|
properties:
|
||||||
index:
|
index:
|
||||||
type: integer
|
type: integer
|
||||||
playlistIndex
|
playlistIndex:
|
||||||
type: integer
|
type: integer
|
||||||
items:
|
items:
|
||||||
type: array
|
type: array
|
||||||
@@ -178,7 +178,7 @@ paths:
|
|||||||
properties:
|
properties:
|
||||||
index:
|
index:
|
||||||
type: integer
|
type: integer
|
||||||
playlistIndex
|
playlistIndex:
|
||||||
type: integer
|
type: integer
|
||||||
items:
|
items:
|
||||||
type: array
|
type: array
|
||||||
@@ -227,6 +227,41 @@ paths:
|
|||||||
description: No Content
|
description: No Content
|
||||||
"400":
|
"400":
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
|
/api/home-layout:
|
||||||
|
get:
|
||||||
|
summary: Get home layout
|
||||||
|
description: Get the current home layout. This is the layout of the home screen, based on user preferences.
|
||||||
|
operationId: getHomeLayout
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
feedSources:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
apiType:
|
||||||
|
type: string
|
||||||
|
endpoint:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
queryParams:
|
||||||
|
type: object
|
||||||
|
additionalProperties: true
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
/api/playlet-lib-urls:
|
/api/playlet-lib-urls:
|
||||||
get:
|
get:
|
||||||
summary: Get Playlet lib URLs
|
summary: Get Playlet lib URLs
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import "HomeScreenUtils.bs"
|
||||||
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
||||||
import "pkg:/components/Navigation/Navigation.bs"
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
import "pkg:/source/utils/FocusManagement.bs"
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
@@ -14,7 +15,15 @@ function OnNodeReady()
|
|||||||
SetNavigation(invalid, "left", m.navBar)
|
SetNavigation(invalid, "left", m.navBar)
|
||||||
|
|
||||||
m.rowList@.BindNode()
|
m.rowList@.BindNode()
|
||||||
m.rowList.feeds = ParseJson(ReadAsciiFile(m.top.feedFile))
|
|
||||||
|
' TODO:P1 home screen should only be refreshed when the user navigates to it
|
||||||
|
' (similar to bookmarks screen)
|
||||||
|
m.preferences.observeFieldScoped("misc.home_screen_layout", FuncName(OnHomeLayoutChange))
|
||||||
|
OnHomeLayoutChange()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnHomeLayoutChange() as void
|
||||||
|
m.rowList.feeds = HomeScreenUtils.GetFeed(m.top.feedFile, m.preferences)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnFocusChange() as void
|
function OnFocusChange() as void
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<interface>
|
<interface>
|
||||||
<field id="navBar" type="node" bind="/NavBar" />
|
<field id="navBar" type="node" bind="/NavBar" />
|
||||||
<field id="invidious" type="node" bind="/Invidious" />
|
<field id="invidious" type="node" bind="/Invidious" />
|
||||||
|
<field id="preferences" type="node" bind="/Preferences" />
|
||||||
<field id="feedFile" type="string" value="libpkg:/config/default_home_layout.yaml" />
|
<field id="feedFile" type="string" value="libpkg:/config/default_home_layout.yaml" />
|
||||||
</interface>
|
</interface>
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
namespace HomeScreenUtils
|
||||||
|
|
||||||
|
function GetFeed(feedFileName as string, preferences as object) as object
|
||||||
|
feed = ParseJson(ReadAsciiFile(feedFileName))
|
||||||
|
|
||||||
|
homeLayout = preferences["misc.home_screen_layout"]
|
||||||
|
if not IsArray(homeLayout) or homeLayout.Count() = 0
|
||||||
|
return feed
|
||||||
|
end if
|
||||||
|
|
||||||
|
feedItems = {}
|
||||||
|
for each item in feed
|
||||||
|
feedItems[item["id"]] = item
|
||||||
|
end for
|
||||||
|
|
||||||
|
filteredFeed = []
|
||||||
|
for each item in homeLayout
|
||||||
|
if item.enabled = true
|
||||||
|
filteredFeed.push(feedItems[item.id])
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
return filteredFeed
|
||||||
|
end function
|
||||||
|
|
||||||
|
end namespace
|
||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||||
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
m.top.focusable = true
|
||||||
|
m.top.itemSpacings = [8]
|
||||||
|
|
||||||
|
m.button = m.top.findNode("button")
|
||||||
|
m.button.observeField("buttonSelected", FuncName(OpenHomeScreenEditor))
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnFocusChange() as void
|
||||||
|
if not m.top.focus
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
NodeSetFocus(m.button, true)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function BindPreference(preferences as object, key as string)
|
||||||
|
if m.preferences <> invalid and m.key <> invalid
|
||||||
|
m.preferences.unobserveFieldScoped(m.key)
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.preferences = preferences
|
||||||
|
m.key = key
|
||||||
|
|
||||||
|
if preferences <> invalid and key <> invalid
|
||||||
|
preferences.observeFieldScoped(key, FuncName(OnPreferenceChange))
|
||||||
|
OnPreferenceChange()
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OpenHomeScreenEditor()
|
||||||
|
editor = CreateObject("roSGNode", "HomeScreenEditor")
|
||||||
|
m.appController@.PushScreen(editor)
|
||||||
|
editor@.BindNode()
|
||||||
|
editor.value = m.top.value
|
||||||
|
editor.observeField("save", FuncName(OnSaveHomeScreenEditor))
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnSaveHomeScreenEditor(event as object)
|
||||||
|
editor = event.GetRoSGNode()
|
||||||
|
m.top.value = editor.value
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnPreferenceChange()
|
||||||
|
m.top.value = m.preferences[m.key]
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnValueChange() as void
|
||||||
|
if m.preferences = invalid or m.key = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.preferences[m.key] = m.top.value
|
||||||
|
end function
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
<component name="EditHomeScreenControl" extends="LayoutGroup" includes="AutoBind,Focus">
|
||||||
|
<interface>
|
||||||
|
<field id="displayText" type="string" alias="Button.text" />
|
||||||
|
<field id="description" type="string" alias="DescriptionLabel.text" />
|
||||||
|
<field id="value" type="array" onChange="OnValueChange" />
|
||||||
|
<field id="appController" type="node" bind="/AppController" />
|
||||||
|
<function name="BindPreference" />
|
||||||
|
</interface>
|
||||||
|
<children>
|
||||||
|
<Button
|
||||||
|
id="button"
|
||||||
|
minWidth="300"
|
||||||
|
showFocusFootprint="true" />
|
||||||
|
<Label id="DescriptionLabel"
|
||||||
|
width="450"
|
||||||
|
color="0xb4b4b4ff"
|
||||||
|
wrap="true">
|
||||||
|
<Font role="font" uri="font:SystemFontFile" size="18" />
|
||||||
|
</Label>
|
||||||
|
</children>
|
||||||
|
</component>
|
||||||
+156
@@ -0,0 +1,156 @@
|
|||||||
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
|
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||||
|
import "pkg:/source/utils/MathUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
m.homeLayout = {}
|
||||||
|
homeLayout = ParseJson(ReadAsciiFile("libpkg:/config/default_home_layout.yaml"))
|
||||||
|
for each item in homeLayout
|
||||||
|
m.homeLayout[item.id] = item
|
||||||
|
end for
|
||||||
|
|
||||||
|
m.checkList = m.top.findNode("checkList")
|
||||||
|
m.moveUpButton = m.top.findNode("moveUpButton")
|
||||||
|
m.moveDownButton = m.top.findNode("moveDownButton")
|
||||||
|
m.closeButton = m.top.findNode("closeButton")
|
||||||
|
m.saveButton = m.top.findNode("saveButton")
|
||||||
|
|
||||||
|
SetNavigation(m.checkList, "down", m.saveButton)
|
||||||
|
SetNavigation(m.saveButton, "up", m.checkList)
|
||||||
|
SetNavigation(m.closeButton, "up", m.checkList)
|
||||||
|
SetNavigation(m.saveButton, "right", m.closeButton)
|
||||||
|
SetNavigation(m.closeButton, "left", m.saveButton)
|
||||||
|
SetNavigation(m.moveUpButton, "left", m.checkList)
|
||||||
|
SetNavigation(m.moveDownButton, "left", m.checkList)
|
||||||
|
SetNavigation(m.checkList, "right", m.moveUpButton)
|
||||||
|
SetNavigation(m.moveUpButton, "down", m.moveDownButton)
|
||||||
|
SetNavigation(m.moveDownButton, "up", m.moveUpButton)
|
||||||
|
SetNavigation(m.moveDownButton, "down", m.closeButton)
|
||||||
|
|
||||||
|
m.moveUpButton.observeField("buttonSelected", FuncName(OnMoveUpButtonSelected))
|
||||||
|
m.moveDownButton.observeField("buttonSelected", FuncName(OnMoveDownButtonSelected))
|
||||||
|
m.saveButton.observeField("buttonSelected", FuncName(OnSaveButtonSelected))
|
||||||
|
m.closeButton.observeField("buttonSelected", FuncName(Close))
|
||||||
|
|
||||||
|
m.checkList.observeField("checkedState", FuncName(OnCheckedStateChange))
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnFocusChange() as void
|
||||||
|
if not m.top.focus
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
NodeSetFocus(m.checkList, true)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||||
|
if NavigationKeyHandler(key, press).handled
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
if key = "options" and press
|
||||||
|
' A pass-through to the app controller, so it can toggle picture-in-picture
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
if key = "back" and press
|
||||||
|
Close()
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnValueChange()
|
||||||
|
content = m.checkList.content
|
||||||
|
value = m.top.value
|
||||||
|
|
||||||
|
nodes = []
|
||||||
|
checkedState = []
|
||||||
|
for each item in value
|
||||||
|
node = CreateObject("roSGNode", "ContentNode")
|
||||||
|
node.id = item.id
|
||||||
|
node.title = m.homeLayout[item.id].title
|
||||||
|
nodes.push(node)
|
||||||
|
checkedState.push(item.enabled)
|
||||||
|
end for
|
||||||
|
|
||||||
|
labelCount = content.getChildCount()
|
||||||
|
if labelCount > 0
|
||||||
|
content.removeChildrenIndex(labelCount, 0)
|
||||||
|
end if
|
||||||
|
|
||||||
|
content.appendChildren(nodes)
|
||||||
|
m.checkList.checkedState = checkedState
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnCheckedStateChange() as void
|
||||||
|
content = m.checkList.content
|
||||||
|
if content = invalid or content.getChildCount() = 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
checkedState = m.checkList.checkedState
|
||||||
|
if checkedState = invalid or checkedState.Count() = 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
value = []
|
||||||
|
checkboxes = content.getChildren(-1, 0)
|
||||||
|
|
||||||
|
for i = 0 to checkboxes.Count() - 1
|
||||||
|
checkbox = checkboxes[i]
|
||||||
|
value.push({
|
||||||
|
id: checkbox.id
|
||||||
|
enabled: checkedState[i]
|
||||||
|
})
|
||||||
|
end for
|
||||||
|
|
||||||
|
m.top.value = value
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnMoveUpButtonSelected() as void
|
||||||
|
MoveItem(-1)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnMoveDownButtonSelected() as void
|
||||||
|
MoveItem(1)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function MoveItem(offset as integer) as void
|
||||||
|
content = m.checkList.content
|
||||||
|
if content = invalid or content.getChildCount() = 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
itemCount = content.getChildCount()
|
||||||
|
index = m.checkList.itemFocused
|
||||||
|
newIndex = MathUtils.Max(0, MathUtils.Min(index + offset, itemCount - 1))
|
||||||
|
|
||||||
|
if index = newIndex
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
checkedState = m.checkList.checkedState
|
||||||
|
node = content.getChild(index)
|
||||||
|
content.insertChild(node, newIndex)
|
||||||
|
|
||||||
|
tmp = checkedState[index]
|
||||||
|
checkedState[index] = checkedState[newIndex]
|
||||||
|
checkedState[newIndex] = tmp
|
||||||
|
|
||||||
|
m.checkList.itemFocused = newIndex
|
||||||
|
m.checkList.jumpToItem = newIndex
|
||||||
|
m.checkList.checkedState = checkedState
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnSaveButtonSelected()
|
||||||
|
' Save the new layout to m.top.value
|
||||||
|
OnCheckedStateChange()
|
||||||
|
m.top.save = true
|
||||||
|
Close()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Close()
|
||||||
|
m.appController@.PopScreen()
|
||||||
|
end function
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
<component name="HomeScreenEditor" extends="Group" includes="AutoBind,Focus">
|
||||||
|
<interface>
|
||||||
|
<field id="value" type="array" onChange="OnValueChange" />
|
||||||
|
<field id="save" type="boolean" alwaysNotify="true" />
|
||||||
|
<field id="appController" type="node" bind="/AppController" />
|
||||||
|
</interface>
|
||||||
|
<children>
|
||||||
|
<Rectangle
|
||||||
|
width="1280"
|
||||||
|
height="720"
|
||||||
|
color="#000000"
|
||||||
|
opacity="0.5">
|
||||||
|
</Rectangle>
|
||||||
|
<Rectangle
|
||||||
|
width="960"
|
||||||
|
height="600"
|
||||||
|
translation="[160,60]"
|
||||||
|
color="#242424">
|
||||||
|
<CheckList
|
||||||
|
id="checkList"
|
||||||
|
vertFocusAnimationStyle="floatingFocus"
|
||||||
|
translation="[164,70]">
|
||||||
|
|
||||||
|
<ContentNode role="content" />
|
||||||
|
</CheckList>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
id="moveUpButton"
|
||||||
|
text="Move up"
|
||||||
|
showFocusFootprint="true"
|
||||||
|
minWidth="220"
|
||||||
|
translation="[640,183]" />
|
||||||
|
<Button
|
||||||
|
id="moveDownButton"
|
||||||
|
text="Move down"
|
||||||
|
showFocusFootprint="true"
|
||||||
|
minWidth="220"
|
||||||
|
translation="[640,273]" />
|
||||||
|
<Button
|
||||||
|
id="closeButton"
|
||||||
|
text="Close"
|
||||||
|
showFocusFootprint="true"
|
||||||
|
minWidth="150"
|
||||||
|
translation="[500,500]" />
|
||||||
|
<Button
|
||||||
|
id="saveButton"
|
||||||
|
text="Save"
|
||||||
|
showFocusFootprint="true"
|
||||||
|
minWidth="150"
|
||||||
|
translation="[320,500]" />
|
||||||
|
</Rectangle>
|
||||||
|
</children>
|
||||||
|
</component>
|
||||||
@@ -2,6 +2,13 @@ import "pkg:/source/utils/RegistryUtils.bs"
|
|||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
|
m.typeMapping = {
|
||||||
|
"boolean": "boolean"
|
||||||
|
"string": "string"
|
||||||
|
"radio": "string"
|
||||||
|
"array": "array"
|
||||||
|
}
|
||||||
|
|
||||||
m.disableSavingToRegistry = false
|
m.disableSavingToRegistry = false
|
||||||
LoadPreferencesFile()
|
LoadPreferencesFile()
|
||||||
AddNodeFields()
|
AddNodeFields()
|
||||||
@@ -25,14 +32,7 @@ end function
|
|||||||
|
|
||||||
function AddNodeFieldsFromPreference(pref as object, fields as object)
|
function AddNodeFieldsFromPreference(pref as object, fields as object)
|
||||||
if pref.key <> invalid and pref.type <> invalid
|
if pref.key <> invalid and pref.type <> invalid
|
||||||
fieldType = ""
|
fieldType = m.typeMapping[pref.type]
|
||||||
if pref.type = "boolean"
|
|
||||||
fieldType = "boolean"
|
|
||||||
else if pref.type = "string"
|
|
||||||
fieldType = "string"
|
|
||||||
else if pref.type = "radio"
|
|
||||||
fieldType = "string"
|
|
||||||
end if
|
|
||||||
m.top.addField(pref.key, fieldType, false)
|
m.top.addField(pref.key, fieldType, false)
|
||||||
fields[pref.key] = true
|
fields[pref.key] = true
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import "pkg:/components/Screens/HomeScreen/HomeScreenUtils.bs"
|
||||||
|
|
||||||
|
namespace Http
|
||||||
|
|
||||||
|
class HomeLayoutRouter extends HttpRouter
|
||||||
|
|
||||||
|
function new()
|
||||||
|
super()
|
||||||
|
|
||||||
|
m.Get("/api/home-layout", function(context as object) as boolean
|
||||||
|
response = context.response
|
||||||
|
task = context.server.task
|
||||||
|
preferences = task.preferences
|
||||||
|
|
||||||
|
feed = HomeScreenUtils.GetFeed("libpkg:/config/default_home_layout.yaml", preferences)
|
||||||
|
response.Json(feed)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end function)
|
||||||
|
|
||||||
|
end function
|
||||||
|
|
||||||
|
end class
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||||
import "pkg:/components/Web/PlayletWebServer/Middleware/BookmarksRouter.bs"
|
import "pkg:/components/Web/PlayletWebServer/Middleware/BookmarksRouter.bs"
|
||||||
import "pkg:/components/Web/PlayletWebServer/Middleware/DashRouter.bs"
|
import "pkg:/components/Web/PlayletWebServer/Middleware/DashRouter.bs"
|
||||||
|
import "pkg:/components/Web/PlayletWebServer/Middleware/HomeLayoutRouter.bs"
|
||||||
import "pkg:/components/Web/PlayletWebServer/Middleware/InvidiousRouter.bs"
|
import "pkg:/components/Web/PlayletWebServer/Middleware/InvidiousRouter.bs"
|
||||||
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayletLibUrlsRouter.bs"
|
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayletLibUrlsRouter.bs"
|
||||||
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayQueueRouter.bs"
|
import "pkg:/components/Web/PlayletWebServer/Middleware/PlayQueueRouter.bs"
|
||||||
@@ -46,6 +47,7 @@ function SetupRoutes(server as object)
|
|||||||
server.UseRouter(new Http.InvidiousRouter())
|
server.UseRouter(new Http.InvidiousRouter())
|
||||||
server.UseRouter(new Http.PlayQueueRouter())
|
server.UseRouter(new Http.PlayQueueRouter())
|
||||||
server.UseRouter(new Http.BookmarksRouter())
|
server.UseRouter(new Http.BookmarksRouter())
|
||||||
|
server.UseRouter(new Http.HomeLayoutRouter())
|
||||||
server.UseRouter(new Http.ViewRouter())
|
server.UseRouter(new Http.ViewRouter())
|
||||||
server.UseRouter(new Http.SearchHistoryRouter())
|
server.UseRouter(new Http.SearchHistoryRouter())
|
||||||
server.UseRouter(new Http.PlayletLibUrlsRouter())
|
server.UseRouter(new Http.PlayletLibUrlsRouter())
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
- title: Subscriptions
|
- title: Subscriptions
|
||||||
|
id: subscriptions
|
||||||
feedSources:
|
feedSources:
|
||||||
- id: inv_auth_feed
|
- id: inv_auth_feed
|
||||||
title: Subscriptions
|
title: Subscriptions
|
||||||
@@ -6,6 +7,7 @@
|
|||||||
endpoint: auth_feed
|
endpoint: auth_feed
|
||||||
|
|
||||||
- title: Trending
|
- title: Trending
|
||||||
|
id: trending
|
||||||
feedSources:
|
feedSources:
|
||||||
- id: inv_trending
|
- id: inv_trending
|
||||||
title: Trending
|
title: Trending
|
||||||
@@ -13,6 +15,7 @@
|
|||||||
endpoint: trending
|
endpoint: trending
|
||||||
|
|
||||||
- title: Trending - Music
|
- title: Trending - Music
|
||||||
|
id: trending_music
|
||||||
feedSources:
|
feedSources:
|
||||||
- id: inv_trending_music
|
- id: inv_trending_music
|
||||||
title: Trending - Music
|
title: Trending - Music
|
||||||
@@ -22,6 +25,7 @@
|
|||||||
type: Music
|
type: Music
|
||||||
|
|
||||||
- title: Trending - Gaming
|
- title: Trending - Gaming
|
||||||
|
id: trending_gaming
|
||||||
feedSources:
|
feedSources:
|
||||||
- id: inv_trending_gaming
|
- id: inv_trending_gaming
|
||||||
title: Trending - Gaming
|
title: Trending - Gaming
|
||||||
@@ -31,6 +35,7 @@
|
|||||||
type: Gaming
|
type: Gaming
|
||||||
|
|
||||||
- title: Trending - Movies
|
- title: Trending - Movies
|
||||||
|
id: trending_movies
|
||||||
feedSources:
|
feedSources:
|
||||||
- id: inv_trending_movies
|
- id: inv_trending_movies
|
||||||
title: Trending - Movies
|
title: Trending - Movies
|
||||||
@@ -40,6 +45,7 @@
|
|||||||
type: Movies
|
type: Movies
|
||||||
|
|
||||||
- title: Popular
|
- title: Popular
|
||||||
|
id: popular
|
||||||
feedSources:
|
feedSources:
|
||||||
- id: inv_popular
|
- id: inv_popular
|
||||||
title: Popular
|
title: Popular
|
||||||
@@ -47,6 +53,7 @@
|
|||||||
endpoint: popular
|
endpoint: popular
|
||||||
|
|
||||||
- title: Playlists
|
- title: Playlists
|
||||||
|
id: playlists
|
||||||
feedSources:
|
feedSources:
|
||||||
- id: inv_auth_playlists
|
- id: inv_auth_playlists
|
||||||
title: Playlists
|
title: Playlists
|
||||||
@@ -54,6 +61,7 @@
|
|||||||
endpoint: auth_playlists
|
endpoint: auth_playlists
|
||||||
|
|
||||||
- title: Watch history
|
- title: Watch history
|
||||||
|
id: watch_history
|
||||||
feedSources:
|
feedSources:
|
||||||
- id: inv_auth_history
|
- id: inv_auth_history
|
||||||
title: Watch history
|
title: Watch history
|
||||||
|
|||||||
@@ -130,6 +130,55 @@
|
|||||||
key: "misc",
|
key: "misc",
|
||||||
description: "Misc. preferences",
|
description: "Misc. preferences",
|
||||||
children: [
|
children: [
|
||||||
|
{
|
||||||
|
displayText: "Edit home screen",
|
||||||
|
key: "misc.home_screen_layout",
|
||||||
|
description: "Edit the home screen feed",
|
||||||
|
type: "array",
|
||||||
|
defaultValue: [
|
||||||
|
{
|
||||||
|
id: "subscriptions",
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "trending",
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "trending_music",
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "trending_gaming",
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "trending_movies",
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "popular",
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "playlists",
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "watch_history",
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
visibility: "tv",
|
||||||
|
rokuComponent: "EditHomeScreenControl",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayText: "Edit home screen",
|
||||||
|
key: "misc.home_screen_layout",
|
||||||
|
description: "Edit the home screen feed",
|
||||||
|
visibility: "web",
|
||||||
|
svelteComponent: "EditHomeScreenControl",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayText: "Queue notifications",
|
displayText: "Queue notifications",
|
||||||
key: "misc.queue_notifications",
|
key: "misc.queue_notifications",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
appStateStore,
|
appStateStore,
|
||||||
bookmarksStore,
|
bookmarksStore,
|
||||||
homeLayoutFileStore,
|
homeLayoutFileStore,
|
||||||
|
homeLayoutStore,
|
||||||
invidiousVideoApiStore,
|
invidiousVideoApiStore,
|
||||||
playletStateStore,
|
playletStateStore,
|
||||||
preferencesModelStore,
|
preferencesModelStore,
|
||||||
@@ -27,6 +28,10 @@
|
|||||||
playletStateStore.set(value);
|
playletStateStore.set(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
PlayletApi.getHomeLayout().then((value) => {
|
||||||
|
homeLayoutStore.set(value);
|
||||||
|
});
|
||||||
|
|
||||||
PlayletApi.getHomeLayoutFile().then((value) => {
|
PlayletApi.getHomeLayoutFile().then((value) => {
|
||||||
homeLayoutFileStore.set(value);
|
homeLayoutFileStore.set(value);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,6 +13,12 @@ export class PlayletApi {
|
|||||||
return await response.json();
|
return await response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Home layout is the home layout file, but with the user's preferences applied.
|
||||||
|
static async getHomeLayout() {
|
||||||
|
const response = await fetch(`${PlayletApi.host()}/api/home-layout`);
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
|
||||||
static async getHomeLayoutFile() {
|
static async getHomeLayoutFile() {
|
||||||
const response = await fetch(`${PlayletApi.host()}/config/default_home_layout.yaml`);
|
const response = await fetch(`${PlayletApi.host()}/config/default_home_layout.yaml`);
|
||||||
return await response.json();
|
return await response.json();
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import VideoListRow from "lib/VideoFeed/VideoListRow.svelte";
|
import VideoListRow from "lib/VideoFeed/VideoListRow.svelte";
|
||||||
import { homeLayoutFileStore } from "lib/Stores";
|
import { homeLayoutStore } from "lib/Stores";
|
||||||
|
|
||||||
export let visibility: boolean;
|
export let visibility: boolean;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={visibility ? "" : "hidden"}>
|
<div class={visibility ? "" : "hidden"}>
|
||||||
<!-- TODO:P0 Handle authenticated feed when not logged in -->
|
<!-- TODO:P0 Handle authenticated feed when not logged in -->
|
||||||
{#each $homeLayoutFileStore as feed}
|
{#each $homeLayoutStore as feed}
|
||||||
<VideoListRow {feed} />
|
<VideoListRow {feed} />
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import {
|
||||||
|
homeLayoutFileStore,
|
||||||
|
homeLayoutStore,
|
||||||
|
userPreferencesStore,
|
||||||
|
} from "lib/Stores";
|
||||||
|
import ArrowUpIcon from "assets/remote-control/arrow-up.svg.svelte";
|
||||||
|
import ArrowDownIcon from "assets/remote-control/arrow-down.svg.svelte";
|
||||||
|
import { PlayletApi } from "lib/Api/PlayletApi";
|
||||||
|
|
||||||
|
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
|
||||||
|
|
||||||
|
export let displayText: string = "";
|
||||||
|
// svelte-ignore unused-export-let
|
||||||
|
export let key: string = "";
|
||||||
|
export let description: string = "";
|
||||||
|
export let level: number = 0;
|
||||||
|
|
||||||
|
let value;
|
||||||
|
let originalValue;
|
||||||
|
let homeLayout;
|
||||||
|
userPreferencesStore.subscribe((userPreferences) => {
|
||||||
|
originalValue = userPreferences[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
homeLayoutFileStore.subscribe((value) => {
|
||||||
|
homeLayout = value.reduce((acc, cur) => {
|
||||||
|
acc[cur.id] = cur;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
});
|
||||||
|
|
||||||
|
let modal;
|
||||||
|
|
||||||
|
async function openHomeScreenEditor() {
|
||||||
|
value = JSON.parse(JSON.stringify(originalValue));
|
||||||
|
modal.showModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
if (key !== "" && value) {
|
||||||
|
await PlayletApi.saveUserPreference(key, value);
|
||||||
|
|
||||||
|
const refreshUserPrefrences = PlayletApi.getUserPreferences();
|
||||||
|
refreshUserPrefrences.then((value) => {
|
||||||
|
userPreferencesStore.set(value);
|
||||||
|
});
|
||||||
|
|
||||||
|
const refreshHomeLayout = PlayletApi.getHomeLayout();
|
||||||
|
refreshHomeLayout.then((value) => {
|
||||||
|
homeLayoutStore.set(value);
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.all([refreshUserPrefrences, refreshHomeLayout]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onClose() {
|
||||||
|
// Reset value to original value to avoid weird animation on show
|
||||||
|
value = JSON.parse(JSON.stringify(originalValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveUp(index) {
|
||||||
|
if (index > 0) {
|
||||||
|
const updatedValue = [...value];
|
||||||
|
[updatedValue[index - 1], updatedValue[index]] = [
|
||||||
|
updatedValue[index],
|
||||||
|
updatedValue[index - 1],
|
||||||
|
];
|
||||||
|
value = updatedValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveDown(index) {
|
||||||
|
if (index < value.length - 1) {
|
||||||
|
const updatedValue = [...value];
|
||||||
|
[updatedValue[index], updatedValue[index + 1]] = [
|
||||||
|
updatedValue[index + 1],
|
||||||
|
updatedValue[index],
|
||||||
|
];
|
||||||
|
value = updatedValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="m-5">
|
||||||
|
<div class={textSizes[level]}>{displayText}</div>
|
||||||
|
<div class="text-xs text-gray-500">{@html description}</div>
|
||||||
|
<button class="btn m-1" on:click={openHomeScreenEditor}
|
||||||
|
>Edit home screen</button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<dialog bind:this={modal} on:close={onClose} class="modal">
|
||||||
|
<div class="modal-box bg-base-100">
|
||||||
|
{#if value && homeLayout}
|
||||||
|
<table class="w-full">
|
||||||
|
{#each value as item, i (i)}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<div class="tooltip" data-tip="Move up">
|
||||||
|
<button
|
||||||
|
class="btn btn-outline btn-sm"
|
||||||
|
on:click={() => moveUp(i)}
|
||||||
|
disabled={i === 0}
|
||||||
|
>
|
||||||
|
<ArrowUpIcon />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<label class="label p-0 cursor-pointer">
|
||||||
|
<div class="label-text">{homeLayout[item.id].title}</div>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name={item.id}
|
||||||
|
bind:checked={item.enabled}
|
||||||
|
class="toggle toggle-primary"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="text-right">
|
||||||
|
<div class="tooltip" data-tip="Move down">
|
||||||
|
<button
|
||||||
|
class="btn btn-outline btn-sm m-2"
|
||||||
|
on:click={() => moveDown(i)}
|
||||||
|
disabled={i === value.length - 1}
|
||||||
|
>
|
||||||
|
<ArrowDownIcon />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</table>
|
||||||
|
<form method="dialog" class="flex justify-center">
|
||||||
|
<button class="btn btn-primary" on:click={save}>Save</button>
|
||||||
|
</form>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<form method="dialog" class="modal-backdrop">
|
||||||
|
<button>Close</button>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import BooleanControl from "lib/Screens/Settings/SettingControls/BooleanControl.svelte";
|
import BooleanControl from "lib/Screens/Settings/SettingControls/BooleanControl.svelte";
|
||||||
import ClearSearchHistoryControl from "lib/Screens/Settings/SettingControls/ClearSearchHistoryControl.svelte";
|
import ClearSearchHistoryControl from "lib/Screens/Settings/SettingControls/ClearSearchHistoryControl.svelte";
|
||||||
|
import EditHomeScreenControl from "lib/Screens/Settings/SettingControls/EditHomeScreenControl.svelte";
|
||||||
import RadioControl from "lib/Screens/Settings/SettingControls/RadioControl.svelte";
|
import RadioControl from "lib/Screens/Settings/SettingControls/RadioControl.svelte";
|
||||||
import StringControl from "lib/Screens/Settings/SettingControls/StringControl.svelte";
|
import StringControl from "lib/Screens/Settings/SettingControls/StringControl.svelte";
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
|
|
||||||
const customComponents = {
|
const customComponents = {
|
||||||
ClearSearchHistoryControl,
|
ClearSearchHistoryControl,
|
||||||
|
EditHomeScreenControl,
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ export const userPreferencesStore = writable({} as any);
|
|||||||
|
|
||||||
export const invidiousVideoApiStore = writable({} as any);
|
export const invidiousVideoApiStore = writable({} as any);
|
||||||
|
|
||||||
|
export const homeLayoutStore = writable([] as any);
|
||||||
|
|
||||||
export const homeLayoutFileStore = writable([] as any);
|
export const homeLayoutFileStore = writable([] as any);
|
||||||
|
|
||||||
export const bookmarksStore = writable([] as any);
|
export const bookmarksStore = writable([] as any);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
// TODO:P1 figure out why some uncached feeds (e.g. channels/ucid/videos) get hit twice
|
// TODO:P1 figure out why some uncached feeds (e.g. channels/ucid/videos) get hit twice
|
||||||
export let feed: any = undefined;
|
export let feed: any = undefined;
|
||||||
export let videos = [];
|
let videos = [];
|
||||||
|
|
||||||
enum FeedLoadState {
|
enum FeedLoadState {
|
||||||
None,
|
None,
|
||||||
@@ -28,6 +28,8 @@
|
|||||||
let scrollStart = 0;
|
let scrollStart = 0;
|
||||||
let scrollEnd = 0;
|
let scrollEnd = 0;
|
||||||
|
|
||||||
|
let loadDataTask = undefined;
|
||||||
|
|
||||||
// w-80|w-60 p-2: 320px|240px + 16px padding on each side
|
// w-80|w-60 p-2: 320px|240px + 16px padding on each side
|
||||||
const videoItemWidth = 320 + 16 * 2;
|
const videoItemWidth = 320 + 16 * 2;
|
||||||
const channelItemWidth = 240 + 16 * 2;
|
const channelItemWidth = 240 + 16 * 2;
|
||||||
@@ -42,6 +44,18 @@
|
|||||||
{ threshold: [0] }
|
{ threshold: [0] }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if (feed) {
|
||||||
|
feedSourcesIndex = 0;
|
||||||
|
feedLoadState = FeedLoadState.None;
|
||||||
|
videos = [];
|
||||||
|
itemWidths = [];
|
||||||
|
scrollStart = 0;
|
||||||
|
scrollEnd = 0;
|
||||||
|
loadDataTask = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (
|
if (
|
||||||
carouselElement &&
|
carouselElement &&
|
||||||
@@ -112,8 +126,6 @@
|
|||||||
loadDataTask = undefined;
|
loadDataTask = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
let loadDataTask;
|
|
||||||
|
|
||||||
async function loadData() {
|
async function loadData() {
|
||||||
feedLoadState = FeedLoadState.Loading;
|
feedLoadState = FeedLoadState.Loading;
|
||||||
let totalFetchedItems = 0;
|
let totalFetchedItems = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user