mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-21 05:59:35 +01:00
core: get rid of subscription.type (all subs now use .plan)
This commit is contained in:
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import {
|
||||
planToId,
|
||||
SubscriptionPlan,
|
||||
SubscriptionType,
|
||||
SubscriptionStatus,
|
||||
User
|
||||
} from "../types.js";
|
||||
import hosts from "../utils/constants.js";
|
||||
@@ -241,12 +241,8 @@ export default class Subscriptions {
|
||||
}
|
||||
|
||||
function isLegacySubscription(user: User) {
|
||||
const type = user.subscription.type;
|
||||
return (
|
||||
type !== undefined &&
|
||||
(type === SubscriptionType.BETA ||
|
||||
type === SubscriptionType.PREMIUM ||
|
||||
type === SubscriptionType.PREMIUM_CANCELED ||
|
||||
type === SubscriptionType.TRIAL)
|
||||
user.subscription.plan === SubscriptionPlan.LEGACY_PRO &&
|
||||
user.subscription.status !== SubscriptionStatus.EXPIRED
|
||||
);
|
||||
}
|
||||
|
||||
@@ -356,7 +356,8 @@ class UserManager {
|
||||
const oldUser = await this.getUser();
|
||||
if (
|
||||
oldUser &&
|
||||
(oldUser.subscription.type !== user.subscription.type ||
|
||||
(oldUser.subscription.plan !== user.subscription.plan ||
|
||||
oldUser.subscription.status !== user.subscription.status ||
|
||||
oldUser.subscription.provider !== user.subscription.provider)
|
||||
) {
|
||||
await this.tokenManager._refreshToken(true);
|
||||
|
||||
@@ -562,7 +562,8 @@ export enum SubscriptionPlan {
|
||||
ESSENTIAL = 1,
|
||||
PRO = 2,
|
||||
BELIEVER = 3,
|
||||
EDUCATION = 4
|
||||
EDUCATION = 4,
|
||||
LEGACY_PRO = 5
|
||||
}
|
||||
|
||||
export enum SubscriptionStatus {
|
||||
@@ -580,16 +581,6 @@ export enum SubscriptionProvider {
|
||||
PADDLE = 3
|
||||
}
|
||||
|
||||
export enum SubscriptionType {
|
||||
BASIC = 0,
|
||||
TRIAL = 1,
|
||||
BETA = 2,
|
||||
PREMIUM = 5,
|
||||
PREMIUM_EXPIRED = 6,
|
||||
PREMIUM_CANCELED = 7,
|
||||
PREMIUM_PAUSED = 8
|
||||
}
|
||||
|
||||
export type User = {
|
||||
id: string;
|
||||
email: string;
|
||||
@@ -615,7 +606,6 @@ export type User = {
|
||||
productId: string;
|
||||
provider: SubscriptionProvider;
|
||||
start: number;
|
||||
type: SubscriptionType;
|
||||
plan: SubscriptionPlan;
|
||||
status: SubscriptionStatus;
|
||||
trialsAvailed?: SubscriptionPlan[];
|
||||
|
||||
Reference in New Issue
Block a user