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 ec59942
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 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
2 changes: 1 addition & 1 deletion src/views/tweet.nim
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; index=0;
if tweet.attribution.isSome:
renderAttribution(tweet.attribution.get(), prefs)

if tweet.card.isSome:
if tweet.card.isSome and tweet.card.get().kind != hidden:
renderCard(tweet.card.get(), prefs, path)

if tweet.photos.len > 0:
Expand Down

0 comments on commit ec59942

Please sign in to comment.