allow extensions to hide themselves.

This commit is contained in:
fiatjaf 2021-03-27 22:10:24 -03:00
parent 61c8d70fe7
commit b2efd71d3c
2 changed files with 14 additions and 1 deletions

View File

@ -15,6 +15,7 @@ class Extension(NamedTuple):
short_description: Optional[str] = None
icon: Optional[str] = None
contributors: Optional[List[str]] = None
hidden: bool = False
class ExtensionManager:
@ -49,6 +50,7 @@ class ExtensionManager:
config.get("short_description"),
config.get("icon"),
config.get("contributors"),
config.get("hidden") or False,
)
)

View File

@ -88,7 +88,15 @@ window.LNbits = {
map: {
extension: function (data) {
var obj = _.object(
['code', 'isValid', 'name', 'shortDescription', 'icon'],
[
'code',
'isValid',
'name',
'shortDescription',
'icon',
'contributors',
'hidden'
],
data
)
obj.url = ['/', obj.code, '/'].join('')
@ -304,6 +312,9 @@ window.windowMixin = {
.map(function (data) {
return window.LNbits.map.extension(data)
})
.filter(function (obj) {
return !obj.hidden
})
.map(function (obj) {
if (user) {
obj.isEnabled = user.extensions.indexOf(obj.code) !== -1