Skip to content

Commit 1716954

Browse files
committed
fix: handle transition to premium correctly
1 parent 9a5293e commit 1716954

File tree

6 files changed

+21
-3
lines changed

6 files changed

+21
-3
lines changed

assets/locales/en/messages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@
291291
"message": "Already have a key? Enter it here",
292292
"description": "Premium activate description."
293293
},
294+
"premium_chatgpt": {
295+
"message": "Your ChatGPT to Notion key will also work here!",
296+
"description": "Premium chatgpt key message"
297+
},
294298
"premium_success": {
295299
"message": "Thanks a lot for your support & purchase! Enjoy autosave and future features as much as you want!",
296300
"description": "Premium success message."

assets/locales/fr/messages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@
283283
"message": "Vous avez déjà une clé ? Entrez-la ici",
284284
"description": "Premium activate description."
285285
},
286+
"premium_chatgpt": {
287+
"message": "Votre clé pour ChatGPT to Notion marche ici aussi !",
288+
"description": "Premium chatgpt key message"
289+
},
286290
"premium_success": {
287291
"message": "Merci beaucoup pour votre achat et votre soutien! Profitez des fonctionnalités premium à votre guise!",
288292
"description": "Premium success message."

src/api/checkSaveConflict.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export const checkSaveConflict = async ({
2020

2121
const storage = new Storage()
2222
const savesLeft = await storage.get<number>("savesLeft")
23+
const isPremium = await storage.get<boolean>("isPremium")
2324

24-
if (savesLeft === 0) throw new Error("No saves left today")
25+
if (!isPremium && savesLeft === 0) throw new Error("No saves left today")
2526

2627
const notion = await getNotion()
2728
const { propertiesIds, tags, tagPropertyIndex, tagIndex } = database

src/popup/IndexPopup.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ function IndexPopup() {
295295
</>
296296
)}
297297
<button
298-
disabled={loading || success || !authenticated || savesLeft <= 0}
298+
disabled={
299+
loading || success || !authenticated || (savesLeft <= 0 && !isPremium)
300+
}
299301
className="button disabled:bg-main"
300302
onClick={() => handleSave()}>
301303
{!authenticated ? (

src/popup/PremiumPopup.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dayjs.extend(localizedFormat)
1414

1515
function PremiumPopup() {
1616
const [isPremium, setPremiumStatus] = useStorage("isPremium", false)
17+
const [savesLeft, setSavesLeft] = useStorage("savesLeft", 10)
1718

1819
const [licenseKey, setLicenseKey] = useState("")
1920
const [loading, setLoading] = useState(false)
@@ -31,6 +32,7 @@ function PremiumPopup() {
3132
const res = await registerKey(licenseKey)
3233
setPremiumStatus(res.success)
3334
setKeyStatus(res.success ? "valid" : "invalid")
35+
if (res.success) setSavesLeft(1000)
3436
} catch (err) {
3537
console.error(err)
3638
} finally {
@@ -118,6 +120,9 @@ function PremiumPopup() {
118120
{keyStatus === "invalid" && i18n("premium_key_activate_error")}
119121
{loading && <Spinner white small />}
120122
</button>
123+
{keyStatus === "unknown" && (
124+
<p className="text-sm">{i18n("premium_chatgpt")}</p>
125+
)}
121126
{/* {keyStatus === "unknown" && (
122127
<>
123128
<div className="my-2 relative w-full">

src/popup/SavePopup.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ export default function SavePopup() {
279279
</>
280280
)}
281281
<button
282-
disabled={loading || success || !authenticated || savesLeft <= 0}
282+
disabled={
283+
loading || success || !authenticated || (savesLeft <= 0 && !isPremium)
284+
}
283285
className="button w-full disabled:bg-main"
284286
onClick={() => handleSave(db!)}>
285287
{!authenticated ? (

0 commit comments

Comments
 (0)