Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/responses/src/Domain/Temp/Subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export type Subscription = {
createdAt: number
updatedAt: number
cancelled: boolean
subscriptionType?: 'regular' | 'shared'
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Props = {

const AccountPreferences = ({ application }: Props) => {
const isUsingThirdPartyServer = !application.sessions.isSignedIntoFirstPartyServer()
const isSharedSubscription = application.subscriptionController.isSharedSubscription

return (
<PreferencesPane>
Expand All @@ -30,7 +31,7 @@ const AccountPreferences = ({ application }: Props) => {
</>
)}
<Subscription />
<SubscriptionSharing application={application} />
{!isSharedSubscription && <SubscriptionSharing application={application} />}
{application.hasAccount() && application.featuresController.entitledToFiles && (
<FilesSection application={application} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useApplication } from '@/Components/ApplicationProvider'

const SubscriptionInformation = () => {
const application = useApplication()
const isSharedSubscription = application.subscriptionController.isSharedSubscription

const manageSubscription = async () => {
void application.openSubscriptionDashboard.execute()
Expand All @@ -13,7 +14,9 @@ const SubscriptionInformation = () => {
return (
<>
<SubscriptionStatusText />
<Button className="mr-3 mt-3 min-w-20" label="Manage subscription" onClick={manageSubscription} />
{!isSharedSubscription && (
<Button className="mr-3 mt-3 min-w-20" label="Manage subscription" onClick={manageSubscription} />
)}
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ const SubscriptionStatusText = () => {
isUserSubscriptionExpired,
isUserSubscriptionCanceled,
} = application.subscriptions
const isSharedSubscription = application.subscriptionController.isSharedSubscription

const expirationDateString = userSubscriptionExpirationDate?.toLocaleString()
const sharedMessage = isSharedSubscription ? (
<>
<br />
<br />
This subscription has been shared with you and can only be managed by the owner.
</>
) : null

if (isUserSubscriptionCanceled) {
return (
Expand All @@ -29,6 +37,7 @@ const SubscriptionStatusText = () => {
<span className="font-bold">but will remain valid until {expirationDateString}</span>
)}
. You may resubscribe below if you wish.
{sharedMessage}
</Text>
)
}
Expand All @@ -43,6 +52,7 @@ const SubscriptionStatusText = () => {
</span>{' '}
subscription <span className="font-bold">expired on {expirationDateString}</span>. You may resubscribe below if
you wish.
{sharedMessage}
</Text>
)
}
Expand All @@ -54,7 +64,7 @@ const SubscriptionStatusText = () => {
Standard Notes{userSubscriptionName ? ' ' : ''}
{userSubscriptionName}
</span>{' '}
subscription will be <span className="font-bold">renewed on {expirationDateString}</span>.
subscription will be <span className="font-bold">renewed on {expirationDateString}</span>.{sharedMessage}
</Text>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class SubscriptionController extends AbstractViewController implements In
hasAccount: observable,
onlineSubscription: observable,

isSharedSubscription: computed,
usedInvitationsCount: computed,
allowedInvitationsCount: computed,
allInvitationsUsed: computed,
Expand Down Expand Up @@ -96,6 +97,10 @@ export class SubscriptionController extends AbstractViewController implements In
return !!this.subscriptions.getOnlineSubscription() || offline
}

get isSharedSubscription(): boolean {
return this.onlineSubscription?.subscriptionType === 'shared'
}

get usedInvitationsCount(): number {
return (
this.subscriptionInvitations?.filter((invitation) =>
Expand Down
Loading