Skip to content

A self-hosted dashboard that puts all your feeds in one place

Make Get return decorated result

Svilen Markov84f72864605b
diff --git a/internal/glance/widget-custom-api.go b/internal/glance/widget-custom-api.go
index 5d82c5a..a7e836e 100644
--- a/internal/glance/widget-custom-api.go
+++ b/internal/glance/widget-custom-api.go
@@ -311,7 +311,7 @@ func gJsonResultArrayToDecoratedResultArray(results []gjson.Result) []decoratedG
}
func (r *decoratedGJSONResult) Exists(key string) bool {
- return r.Get(key).Exists()
+ return r.Result.Get(key).Exists()
}
func (r *decoratedGJSONResult) Array(key string) []decoratedGJSONResult {
@@ -319,7 +319,7 @@ func (r *decoratedGJSONResult) Array(key string) []decoratedGJSONResult {
return gJsonResultArrayToDecoratedResultArray(r.Result.Array())
}
- return gJsonResultArrayToDecoratedResultArray(r.Get(key).Array())
+ return gJsonResultArrayToDecoratedResultArray(r.Result.Get(key).Array())
}
func (r *decoratedGJSONResult) String(key string) string {
@@ -327,7 +327,7 @@ func (r *decoratedGJSONResult) String(key string) string {
return r.Result.String()
}
- return r.Get(key).String()
+ return r.Result.Get(key).String()
}
func (r *decoratedGJSONResult) Int(key string) int {
@@ -335,7 +335,7 @@ func (r *decoratedGJSONResult) Int(key string) int {
return int(r.Result.Int())
}
- return int(r.Get(key).Int())
+ return int(r.Result.Get(key).Int())
}
func (r *decoratedGJSONResult) Float(key string) float64 {
@@ -343,7 +343,7 @@ func (r *decoratedGJSONResult) Float(key string) float64 {
return r.Result.Float()
}
- return r.Get(key).Float()
+ return r.Result.Get(key).Float()
}
func (r *decoratedGJSONResult) Bool(key string) bool {
@@ -351,7 +351,11 @@ func (r *decoratedGJSONResult) Bool(key string) bool {
return r.Result.Bool()
}
- return r.Get(key).Bool()
+ return r.Result.Get(key).Bool()
+}
+
+func (r *decoratedGJSONResult) Get(key string) *decoratedGJSONResult {
+ return &decoratedGJSONResult{r.Result.Get(key)}
}
func customAPIDoMathOp[T int | float64](a, b T, op string) T {