Announcements - do not show again

This commit is contained in:
Brahim Hadriche committed 2025-01-07 18:13:34 -05:00
1 parent fbac4ab959
commit ec941d64dc
10 files changed
+99 -3

No files matched your search

+6
View File
@@ -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.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Ability to hide annoucement messages
## [0.35.4] - 2025-01-07
### Added
+2 -1
View File
@@ -65,6 +65,7 @@
"update-deps": "npx npm-check-updates --deep --upgrade --install always --reject @sveltejs/vite-plugin-svelte,svelte,vite,@vitejs/plugin-legacy",
"registry:write": "node tools/registry.js --input registry.json",
"registry:read": "node tools/registry.js --output registry.json",
"registry:clear": "node tools/registry.js --clear"
"registry:clear": "node tools/registry.js --clear",
"restart-app": "node tools/restart-app.js --app-id dev"
}
}
@@ -1,4 +1,6 @@
import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/RegistryUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
namespace DialogUtils
@@ -91,4 +93,58 @@ namespace DialogUtils
return dialog
end function
function ShowDialogOnce(options as object) as object
messageId = ValidString(options.messageId)
hasMessageId = messageId <> ""
if hasMessageId
messages = RegistryUtils.Read(RegistryUtils.MESSAGES)
if not StringUtils.IsNullOrEmpty(messages)
messages = ParseJson(messages)
if IsAssociativeArray(messages)
savedMessageId = ValidString(messages["messageId"])
if savedMessageId = messageId
return invalid
end if
end if
end if
end if
options.buttons = [
Tr(Locale.Buttons.OK)
`${Tr(Locale.Buttons.OK)} - ${Tr(Locale.Buttons.DotNotShowAgain)}`
]
dialog = ShowDialogEx(options)
if dialog = invalid
return invalid
end if
dialog.AddFields({
"messageId": messageId
})
dialog.ObserveField("buttonSelected", FuncName(OnShowDialogOnceButtonSelected))
return dialog
end function
function OnShowDialogOnceButtonSelected(event as object) as void
buttonSelected = event.getData()
if buttonSelected <> 1
return
end if
dialog = event.GetRoSGNode()
messageId = dialog.messageId
if messageId = ""
return
end if
messages = {
"messageId": messageId
}
RegistryUtils.Write(RegistryUtils.MESSAGES, FormatJson(messages))
end function
end namespace
+2 -1
View File
@@ -35,7 +35,8 @@ function StartWebServer()
end function
function ShowAnnouncement()
DialogUtils.ShowDialogEx({
DialogUtils.ShowDialogOnce({
messageId: "1736288537"
title: "Announcement - Playlet backend"
message: [
"An experimental built-in backend has been added to Playlet."
@@ -34,7 +34,8 @@ function StartWebServer()
end function
function ShowAnnouncement()
DialogUtils_ShowDialogEx({
DialogUtils_ShowDialogOnce({
messageId: "1736288537"
title: "Announcement - Playlet backend"
message: [
"An experimental built-in backend has been added to Playlet."
@@ -17,6 +17,7 @@
<script type="text/brightscript" uri="pkg:/source/utils/StringUtils.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/Logging.brs" />
<script type="text/brightscript" uri="pkg:/components/Dialog/DialogUtils.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/RegistryUtils.brs" />
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
<children>
<Logger id="Logger" />
@@ -36,6 +36,10 @@
<source>OK</source>
<translation>OK</translation>
</message>
<message>
<source>Do not show again</source>
<translation>Do not show again</translation>
</message>
<message>
<source>Activate</source>
<translation>Activate</translation>
+1
View File
@@ -14,6 +14,7 @@ namespace Locale
@locale
enum Buttons
OK = "OK"
DotNotShowAgain = "Do not show again"
Activate = "Activate"
InUse = "In Use"
Login = "Login"
@@ -8,6 +8,7 @@ namespace RegistryUtils
const SEARCH_HISTORY = "search_history"
const PLAYLET_LIB_URLS = "playlet_lib_urls"
const BOOKMARKS = "bookmarks"
const MESSAGES = "messages"
const LAST_LOUNGE_DATA = "last_lounge_data"
+24
View File
@@ -0,0 +1,24 @@
// Restarts the Roku app
const { ArgumentParser } = require('argparse');
const getEnvVars = require('./get-env-vars');
const config = getEnvVars(['ROKU_DEV_TARGET']);
(async () => {
const parser = new ArgumentParser({
description: 'Restart Roku app using ECP'
});
parser.add_argument('--app-id', { help: 'App Id' });
const args = parser.parse_args();
const appId = args.app_id
const url = `http://${config.ROKU_DEV_TARGET}:8060/launch/${appId}?restart=true`;
console.log("Restarting app", appId);
await fetch(url, {
method: 'POST',
body: '',
});
})();