mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2025-12-10 05:39:38 +05:00
preference to dynamically load comments and small fixes
This commit is contained in:
@@ -134,6 +134,7 @@ func defaultPreferences() {
|
||||
DefaultPreferences.ShowAudio = &False
|
||||
|
||||
DefaultPreferences.SearchSuggestions = &False
|
||||
DefaultPreferences.DynamicLoadComments = &False
|
||||
}
|
||||
|
||||
func loadDefaultPreferences(loaded Preferences) {
|
||||
@@ -216,6 +217,12 @@ func loadDefaultPreferences(loaded Preferences) {
|
||||
} else {
|
||||
DefaultPreferences.SearchSuggestions = &False
|
||||
}
|
||||
|
||||
if loaded.DynamicLoadComments != nil {
|
||||
DefaultPreferences.DynamicLoadComments = loaded.DynamicLoadComments
|
||||
} else {
|
||||
DefaultPreferences.DynamicLoadComments = &False
|
||||
}
|
||||
}
|
||||
|
||||
func boolean(in string) bool {
|
||||
@@ -240,7 +247,7 @@ func fromEnv() error {
|
||||
env = os.Getenv("DEFAULT_PREFERENCES")
|
||||
if env != "" {
|
||||
var p Preferences
|
||||
err := json.Unmarshal([]byte(env), &p)
|
||||
err := json.Unmarshal(S2b(env), &p)
|
||||
if err != nil {
|
||||
return wrappedError{err, "DEFAULT_PREFERENCES"}
|
||||
}
|
||||
@@ -383,7 +390,7 @@ func fromEnv() error {
|
||||
env = os.Getenv("TRUSTED_PROXIES")
|
||||
if env != "" {
|
||||
var p []string
|
||||
err := json.Unmarshal([]byte(env), &p)
|
||||
err := json.Unmarshal(S2b(env), &p)
|
||||
if err != nil {
|
||||
return wrappedError{err, "TRUSTED_PROXIES"}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package cfg
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// seems soundcloud has 4 of these (i1, i2, i3, i4)
|
||||
// they point to the same ip from my observations, and they all serve the same files
|
||||
const ImageCDN = "i1.sndcdn.com"
|
||||
@@ -67,4 +69,14 @@ type Preferences struct {
|
||||
ShowAudio *bool // display audio (aac, opus, mpeg etc) under track player
|
||||
|
||||
SearchSuggestions *bool // load search suggestions on main page
|
||||
|
||||
DynamicLoadComments *bool // dynamic comments loader without leaving track page
|
||||
}
|
||||
|
||||
func B2s(b []byte) string {
|
||||
return unsafe.String(unsafe.SliceData(b), len(b))
|
||||
}
|
||||
|
||||
func S2b(s string) []byte {
|
||||
return unsafe.Slice(unsafe.StringData(s), len(s))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user