Skip to content

Commit 60c391d

Browse files
authored
tooltip text from server (#23596)
1 parent e08154f commit 60c391d

6 files changed

Lines changed: 19 additions & 31 deletions

File tree

go/invitefriends/api.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ var (
1414

1515
func GetCounts(mctx libkb.MetaContext) (counts keybase1.InviteCounts, err error) {
1616
type apiRes struct {
17-
NumInvitesInLastDay int `json:"numInvitesInLastDay"`
18-
PercentageChange float64 `json:"percentageChange"`
19-
ShowNumInvites bool `json:"showNumInvites"`
20-
ShowFire bool `json:"showFire"`
17+
NumInvites int `json:"numInvites"`
18+
PercentageChange float64 `json:"percentageChange"`
19+
ShowNumInvites bool `json:"showNumInvites"`
20+
ShowFire bool `json:"showFire"`
21+
TooltipMarkdown string `json:"tooltipMarkdown"`
2122
libkb.AppStatusEmbed
2223
}
2324
apiArg := libkb.APIArg{
24-
Endpoint: "invite_friends/num_invites_in_last_day",
25+
Endpoint: "invite_friends/num_invites",
2526
SessionType: libkb.APISessionTypeNONE,
2627
}
2728
var res apiRes
@@ -30,10 +31,11 @@ func GetCounts(mctx libkb.MetaContext) (counts keybase1.InviteCounts, err error)
3031
return counts, err
3132
}
3233
newCounts := keybase1.InviteCounts{
33-
InviteCount: res.NumInvitesInLastDay,
34+
InviteCount: res.NumInvites,
3435
PercentageChange: res.PercentageChange,
3536
ShowNumInvites: res.ShowNumInvites,
3637
ShowFire: res.ShowFire,
38+
TooltipMarkdown: res.TooltipMarkdown,
3739
}
3840
countsCacheMu.Lock()
3941
countsCache = &newCounts

go/protocol/keybase1/invite_friends.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protocol/avdl/keybase1/invite_friends.avdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ protocol inviteFriends {
88
double percentageChange; // vs the previous 24 hours
99
boolean showNumInvites;
1010
boolean showFire; // Are keybase servers on fire?
11+
string tooltipMarkdown; // Tooltip text
1112
}
1213

1314
record EmailInvites {

protocol/json/keybase1/invite_friends.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shared/constants/types/rpc-gen.tsx

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shared/people/invite-friends/tab-bar-button.tsx

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const InviteFriends = () => {
4545
)
4646

4747
let inviteCounter: React.ReactNode = null
48-
let firstTooltipLine = ''
4948
if (inviteCounts?.showNumInvites) {
5049
inviteCounter = (
5150
<Kb.Box2 direction="horizontal" gap="tiny" centerChildren={true}>
@@ -56,16 +55,16 @@ const InviteFriends = () => {
5655
</Kb.Text>
5756
</Kb.Box2>
5857
)
59-
firstTooltipLine = `${inviteCounts.inviteCount.toLocaleString()} friends invited in the last 24 hours.`
6058
}
59+
const tooltipMarkdown = <Kb.Markdown style={styles.tooltip}>{inviteCounts?.tooltipMarkdown}</Kb.Markdown>
6160

6261
return Styles.isMobile ? (
6362
<Kb.Box2 direction="horizontal" fullWidth={true} style={styles.mobileContainer}>
6463
<Kb.Box style={Styles.globalStyles.flexOne} />
6564
{inviteButton}
6665
{inviteCounter ? (
6766
<Kb.Box2 direction="horizontal" style={styles.inviteCounterBox}>
68-
<Kb.WithTooltip tooltip={firstTooltipLine} showOnPressMobile={true}>
67+
<Kb.WithTooltip tooltip={tooltipMarkdown} showOnPressMobile={true}>
6968
{inviteCounter}
7069
</Kb.WithTooltip>
7170
</Kb.Box2>
@@ -82,27 +81,7 @@ const InviteFriends = () => {
8281
<Kb.Box2 direction="vertical" gap="xsmall" style={styles.container} className="invite-friends-big">
8382
{inviteButton}
8483
{!!inviteCounter && inviteCounts && (
85-
<Kb.WithTooltip
86-
tooltip={
87-
<Kb.Box2 direction="vertical" alignItems="flex-start">
88-
<Kb.Text type="BodySmall" style={styles.tooltip}>
89-
{firstTooltipLine}
90-
</Kb.Text>
91-
{inviteCounts.percentageChange > 0 ? (
92-
<Kb.Text type="BodySmall" style={styles.tooltip}>
93-
That's {inviteCounts.percentageChange}% more than yesterday.
94-
</Kb.Text>
95-
) : null}
96-
{inviteCounts.showFire ? (
97-
<Kb.Text type="BodySmall" style={styles.tooltip}>
98-
Keybase servers are on fire! <Kb.Emoji emojiName=":fire:" size={12} />
99-
</Kb.Text>
100-
) : null}
101-
</Kb.Box2>
102-
}
103-
>
104-
{inviteCounter}
105-
</Kb.WithTooltip>
84+
<Kb.WithTooltip tooltip={tooltipMarkdown}>{inviteCounter}</Kb.WithTooltip>
10685
)}
10786
</Kb.Box2>
10887
<Kb.ClickableBox

0 commit comments

Comments
 (0)