Move graphql_color_to_enum -> ThreadColor._from_graphql
This commit is contained in:
@@ -2577,7 +2577,7 @@ class Client(object):
|
|||||||
|
|
||||||
# Color change
|
# Color change
|
||||||
elif delta_type == "change_thread_theme":
|
elif delta_type == "change_thread_theme":
|
||||||
new_color = graphql_color_to_enum(delta["untypedData"]["theme_color"])
|
new_color = ThreadColor._from_graphql(delta["untypedData"]["theme_color"])
|
||||||
thread_id, thread_type = getThreadIdAndThreadType(metadata)
|
thread_id, thread_type = getThreadIdAndThreadType(metadata)
|
||||||
self.onColorChange(
|
self.onColorChange(
|
||||||
mid=mid,
|
mid=mid,
|
||||||
|
@@ -27,16 +27,6 @@ class ConcatJSONDecoder(json.JSONDecoder):
|
|||||||
# End shameless copy
|
# End shameless copy
|
||||||
|
|
||||||
|
|
||||||
def graphql_color_to_enum(color):
|
|
||||||
if color is None:
|
|
||||||
return None
|
|
||||||
if not color:
|
|
||||||
return ThreadColor.MESSENGER_BLUE
|
|
||||||
color = color[2:] # Strip the alpha value
|
|
||||||
color_value = "#{}".format(color.lower())
|
|
||||||
return ThreadColor._extend_if_invalid(color_value)
|
|
||||||
|
|
||||||
|
|
||||||
def get_customization_info(thread):
|
def get_customization_info(thread):
|
||||||
if thread is None or thread.get("customization_info") is None:
|
if thread is None or thread.get("customization_info") is None:
|
||||||
return {}
|
return {}
|
||||||
@@ -44,7 +34,7 @@ def get_customization_info(thread):
|
|||||||
|
|
||||||
rtn = {
|
rtn = {
|
||||||
"emoji": info.get("emoji"),
|
"emoji": info.get("emoji"),
|
||||||
"color": graphql_color_to_enum(info.get("outgoing_bubble_color")),
|
"color": ThreadColor._from_graphql(info.get("outgoing_bubble_color")),
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
thread.get("thread_type") == "GROUP"
|
thread.get("thread_type") == "GROUP"
|
||||||
|
@@ -42,6 +42,16 @@ class ThreadColor(Enum):
|
|||||||
BRILLIANT_ROSE = "#ff5ca1"
|
BRILLIANT_ROSE = "#ff5ca1"
|
||||||
BILOBA_FLOWER = "#a695c7"
|
BILOBA_FLOWER = "#a695c7"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _from_graphql(cls, color):
|
||||||
|
if color is None:
|
||||||
|
return None
|
||||||
|
if not color:
|
||||||
|
return cls.MESSENGER_BLUE
|
||||||
|
color = color[2:] # Strip the alpha value
|
||||||
|
value = "#{}".format(color.lower())
|
||||||
|
return cls._extend_if_invalid(value)
|
||||||
|
|
||||||
|
|
||||||
@attr.s(cmp=False, init=False)
|
@attr.s(cmp=False, init=False)
|
||||||
class Thread(object):
|
class Thread(object):
|
||||||
|
@@ -8,7 +8,6 @@ from ._graphql import (
|
|||||||
FLAGS,
|
FLAGS,
|
||||||
WHITESPACE,
|
WHITESPACE,
|
||||||
ConcatJSONDecoder,
|
ConcatJSONDecoder,
|
||||||
graphql_color_to_enum,
|
|
||||||
get_customization_info,
|
get_customization_info,
|
||||||
graphql_to_sticker,
|
graphql_to_sticker,
|
||||||
graphql_to_attachment,
|
graphql_to_attachment,
|
||||||
|
Reference in New Issue
Block a user