mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-05 01:19:29 +00:00
Feat global state (#861)
* add zustand, add auth store * add user config store, isAdmin from store * move ColourVariants, fix importColours * get userConfig from store * fix name conflict * home filter bar from config store * use user store for channel list * use userConfig store for channel pages * use userConfig for playlist pages * fix channel video type navigation * use userConfig update on downloads page * fix view style in search * handle initial user config, take 2 * modify userSettings in global state
This commit is contained in:
@@ -25,7 +25,6 @@ class UserConfigType(TypedDict, total=False):
|
||||
hide_watched: bool
|
||||
show_ignored_only: bool
|
||||
show_subed_only: bool
|
||||
sponsorblock_id: str
|
||||
|
||||
|
||||
class UserConfig:
|
||||
@@ -44,7 +43,6 @@ class UserConfig:
|
||||
hide_watched=False,
|
||||
show_ignored_only=False,
|
||||
show_subed_only=False,
|
||||
sponsorblock_id=None,
|
||||
)
|
||||
|
||||
VALID_STYLESHEETS = get_stylesheets()
|
||||
@@ -134,9 +132,15 @@ class UserConfig:
|
||||
es_document_path = f"ta_config/_doc/user_{self._user_id}"
|
||||
response, status = ElasticWrap(es_document_path).get(print_error=False)
|
||||
if status == 200 and "_source" in response.keys():
|
||||
source = response.get("_source")
|
||||
source = response.get("_source", {})
|
||||
if "config" in source.keys():
|
||||
return source.get("config")
|
||||
|
||||
# There is no config in ES
|
||||
return {}
|
||||
response, status_code = ElasticWrap(es_document_path).put(
|
||||
{"config": dict(self._DEFAULT_USER_SETTINGS)}
|
||||
)
|
||||
if status_code == 200:
|
||||
print(f"set default config for user {self._user_id}: {response}")
|
||||
|
||||
return self._DEFAULT_USER_SETTINGS
|
||||
|
||||
Reference in New Issue
Block a user