Skip to content

Commit

Permalink
Hide US-only commerce cards
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Mar 26, 2023
1 parent 1f9d500 commit 78938f1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/experimental/parser/unifiedcard.nim
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ proc parseUnifiedCard*(json: string): Card =
component.parseMedia(card, result)
of buttonGroup:
discard
of ComponentType.hidden:
result.kind = CardKind.hidden
of ComponentType.unknown:
echo "ERROR: Unknown component type: ", json

Expand Down
6 changes: 4 additions & 2 deletions src/experimental/types/unifiedcard.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type
twitterListDetails
communityDetails
mediaWithDetailsHorizontal
hidden
unknown

Component* = object
Expand Down Expand Up @@ -71,11 +72,11 @@ type
Text = object
content: string

HasTypeField = Component | Destination | MediaEntity | AppStoreData
TypeField = Component | Destination | MediaEntity | AppStoreData

converter fromText*(text: Text): string = text.content

proc renameHook*(v: var HasTypeField; fieldName: var string) =
proc renameHook*(v: var TypeField; fieldName: var string) =
if fieldName == "type":
fieldName = "kind"

Expand All @@ -89,6 +90,7 @@ proc enumHook*(s: string; v: var ComponentType) =
of "twitter_list_details": twitterListDetails
of "community_details": communityDetails
of "media_with_details_horizontal": mediaWithDetailsHorizontal
of "commerce_drop_details": hidden
else: echo "ERROR: Unknown enum value (ComponentType): ", s; unknown

proc enumHook*(s: string; v: var AppType) =
Expand Down
1 change: 1 addition & 0 deletions src/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ type
imageDirectMessage = "image_direct_message"
audiospace = "audiospace"
newsletterPublication = "newsletter_publication"
hidden
unknown

Card* = object
Expand Down

0 comments on commit 78938f1

Please sign in to comment.