diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dc58197..9a7e2750 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index 87a9ba8b..ba9a3868 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/playlet-lib/src/components/Dialog/DialogUtils.bs b/playlet-lib/src/components/Dialog/DialogUtils.bs index 840547bf..5f97c965 100644 --- a/playlet-lib/src/components/Dialog/DialogUtils.bs +++ b/playlet-lib/src/components/Dialog/DialogUtils.bs @@ -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 diff --git a/playlet-lib/src/components/MainScene.bs b/playlet-lib/src/components/MainScene.bs index 513c1b03..b0b8c76a 100644 --- a/playlet-lib/src/components/MainScene.bs +++ b/playlet-lib/src/components/MainScene.bs @@ -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." diff --git a/playlet-lib/src/components/MainScene.transpiled.brs b/playlet-lib/src/components/MainScene.transpiled.brs index 42346bac..e0248b04 100644 --- a/playlet-lib/src/components/MainScene.transpiled.brs +++ b/playlet-lib/src/components/MainScene.transpiled.brs @@ -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." diff --git a/playlet-lib/src/components/MainScene.transpiled.xml b/playlet-lib/src/components/MainScene.transpiled.xml index 6ac902d9..21db3095 100644 --- a/playlet-lib/src/components/MainScene.transpiled.xml +++ b/playlet-lib/src/components/MainScene.transpiled.xml @@ -17,6 +17,7 @@