Skip to content

Commit b9c9421

Browse files
committed
Update to new accounts module & coordinated status
This aligns subscription logic with the cloud logic that'll be used in the remote endpoint service, so we consistently use the same settings everywhere. Also simplifies things - no need for computeds or extra accounts wrappers everywhere.
1 parent e4e1909 commit b9c9421

24 files changed

Lines changed: 66 additions & 108 deletions

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@fortawesome/free-regular-svg-icons": "^5.12.1",
4646
"@fortawesome/free-solid-svg-icons": "^5.12.1",
4747
"@fortawesome/react-fontawesome": "^0.1.8",
48-
"@httptoolkit/accounts": "^3.0.1",
48+
"@httptoolkit/accounts": "^3.1.0",
4949
"@httptoolkit/httpsnippet": "^3.0.2",
5050
"@open-rpc/meta-schema": "^1.14.2",
5151
"@phosphor-icons/react": "^2.1.5",

src/components/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class App extends React.Component<{
9898

9999
@computed
100100
get canVisitSettings() {
101-
return this.props.accountStore.isPaidUser || this.props.accountStore.isPastDueUser;
101+
return this.props.accountStore.user.userHasSubscription();
102102
}
103103

104104
@computed

src/components/modify/modify-page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class ModifyPage extends React.Component<ModifyPageProps> {
150150
updateGroupTitle,
151151
combineDraftRulesAsGroup
152152
} = this.props.rulesStore;
153-
const { isPaidUser } = this.props.accountStore;
153+
const isPaidUser = this.props.accountStore.user.isPaidUser();
154154

155155
return <ModifyPageContainer ref={this.containerRef}>
156156
<ModifyPageHeader>

src/components/modify/rule-row.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,9 @@ export class RuleRow extends React.Component<{
336336
collapsed,
337337
disabled
338338
} = this.props;
339-
const {
340-
isPaidUser,
341-
getPro
342-
} = this.props.accountStore!;
339+
const { accountStore } = this.props;
340+
const isPaidUser = accountStore!.user.isPaidUser();
341+
const { getPro } = accountStore!;
343342

344343
const ruleType = rule.type;
345344
const initialMatcher = rule.matchers.length ? rule.matchers[0] : undefined;

src/components/modify/step-selection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export const StepSelector = inject('rulesStore', 'accountStore')(observer((p: {
196196
}) => {
197197
let [ allowedSteps, needProSteps ] = _.partition(
198198
p.availableSteps,
199-
(stepClass) => p.accountStore!.isPaidUser || !isPaidStepClass(p.ruleType, stepClass)
199+
(stepClass) => p.accountStore!.user.isPaidUser() || !isPaidStepClass(p.ruleType, stepClass)
200200
);
201201

202202
// Pull the breakpoint steps to the top, since they're kind of separate

src/components/send/response-pane.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class ResponsePane extends React.Component<{
7272
/>
7373
<SentResponseBodyCard
7474
{...this.cardProps.responseBody}
75-
isPaidUser={this.props.accountStore!.isPaidUser}
75+
isPaidUser={this.props.accountStore!.user.isPaidUser()}
7676
url={exchange.request.url}
7777
message={response}
7878
editorNode={editorNode}
@@ -126,7 +126,7 @@ export class ResponsePane extends React.Component<{
126126
/>
127127
<SentResponseBodyCard
128128
{...this.cardProps.responseBody}
129-
isPaidUser={this.props.accountStore!.isPaidUser}
129+
isPaidUser={this.props.accountStore!.user.isPaidUser()}
130130
url={requestInput.url}
131131
editorNode={editorNode}
132132
/>

src/components/settings/settings-page.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ class SettingsPage extends React.Component<SettingsPageProps> {
123123
render() {
124124
const { uiStore } = this.props;
125125
const {
126-
isPaidUser,
127-
isPastDueUser,
126+
user,
128127
userEmail,
129128
userSubscription,
130129
subscriptionPlans,
@@ -136,7 +135,7 @@ class SettingsPage extends React.Component<SettingsPageProps> {
136135

137136
const cardProps = uiStore.settingsCardProps;
138137

139-
if (!isPaidUser && !isPastDueUser) {
138+
if (!user.userHasSubscription()) {
140139
// Can only happen if you log out whilst on this page.
141140
return <SettingsPagePlaceholder>
142141
<Button onClick={() => getPro('settings-page')}>Get Pro</Button>
@@ -272,7 +271,7 @@ class SettingsPage extends React.Component<SettingsPageProps> {
272271
The rest is active paid users only:
273272
*/}
274273

275-
{ isPaidUser && <>
274+
{ user.isPaidUser() && <>
276275
{
277276
_.isString(serverVersion.value) &&
278277
versionSatisfies(serverVersion.value, PORT_RANGE_SERVER_RANGE) && <>

src/components/view/filters/search-filter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ export class SearchFilter<T> extends React.Component<{
591591
availableFilters={availableFilters}
592592
suggestionContext={filterSuggestionContext}
593593

594-
isPaidUser={accountStore!.isPaidUser}
594+
isPaidUser={accountStore!.user.isPaidUser()}
595595
getPro={accountStore!.getPro}
596596
/>
597597
{ hasContents

src/components/view/http/header-details.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export const HeaderDetails = inject('accountStore')(observer((props: {
194194
key,
195195
value,
196196
props.requestUrl,
197-
props.accountStore!.isPaidUser
197+
props.accountStore!.user.isPaidUser()
198198
)
199199

200200
return <CollapsibleSection

0 commit comments

Comments
 (0)