aboutsummaryrefslogtreecommitdiffstats
path: root/settings.py
diff options
context:
space:
mode:
Diffstat (limited to 'settings.py')
-rw-r--r--settings.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/settings.py b/settings.py
index 5407922..517e785 100644
--- a/settings.py
+++ b/settings.py
@@ -286,6 +286,14 @@ if route_tor:
else:
print("Tor routing is OFF - your Youtube activity is NOT anonymous")
+hooks = {}
+def add_setting_changed_hook(setting, func):
+ '''Called right before new settings take effect'''
+ if setting in hooks:
+ hooks[setting].append(func)
+ else:
+ hooks[setting] = [func]
+
def settings_page():
if request.method == 'GET':
@@ -309,6 +317,13 @@ def settings_page():
assert settings_info[setting_name]['type'] is bool, missing_inputs
settings[setting_name] = False
+ # call setting hooks
+ for setting_name, value in settings.items():
+ old_value = globals()[setting_name]
+ if value != old_value and setting_name in hooks:
+ for func in hooks[setting_name]:
+ func(old_value, value)
+
globals().update(settings)
save_settings(settings)
return flask.redirect(util.URL_ORIGIN + '/settings', 303)