Skip to content

Commit 3115209

Browse files
organize early-access related code
1 parent 42ef6a6 commit 3115209

File tree

8 files changed

+40
-24
lines changed

8 files changed

+40
-24
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./use-early-access";
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React, { useEffect, useState } from "react";
2+
import store from "../store";
3+
4+
export function useEarlyAccess() {
5+
const [accesskey, setAccessKey] = useState<string | null>(null);
6+
useEffect(() => {
7+
store.get().then((d) => {
8+
if (d) {
9+
setAccessKey(d);
10+
}
11+
});
12+
}, []);
13+
14+
return accesskey;
15+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export { UpgradePage } from "./register";
2+
export * from "./hooks";
3+
export { default as store } from "./store";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const __key = "assistant-early-access-activation";

packages/_firstparty-early-access/scaffolds/register-with-code-card.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { useState, useEffect } from "react";
22
import styled from "@emotion/styled";
33
import { PluginSdk } from "@plugin-sdk/app";
4-
5-
const __key = "assistant-early-access-activation";
4+
import { store } from "@assistant-fp/early-access";
65

76
const __form_key_min_length = 24;
87

@@ -11,7 +10,7 @@ export function RegisterWithCodeCard() {
1110
const [isTokenFormatValid, setIsTokenFormatValid] = useState(false);
1211

1312
useEffect(() => {
14-
PluginSdk.getItem(__key).then((code) => {
13+
store.get().then((code) => {
1514
verify(code).then((verified) => {
1615
setVerified(verified);
1716
});
@@ -36,7 +35,7 @@ export function RegisterWithCodeCard() {
3635
const activate = (code: string) => {
3736
verify(code).then((verified) => {
3837
if (verified) {
39-
PluginSdk.setItem(__key, code);
38+
store.set(code);
4039
setVerified(true);
4140
alert("Congrats🎉 Early access program activated.");
4241
} else {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { __key } from "./k";
2+
import { PluginSdk } from "@plugin-sdk/app";
3+
4+
const store = {
5+
set: (value: any) => {
6+
return PluginSdk.setItem(__key, value);
7+
},
8+
get: async () => {
9+
return await PluginSdk.getItem(__key);
10+
},
11+
};
12+
13+
export default store;

packages/app-photo-loader/photo-loader.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import InfiniteScroll from "react-infinite-scroller";
1313
import { useHistory } from "react-router-dom";
1414
import { radmon_query_placeholder } from "./k";
1515
import { ImagePromptBox } from "./image-prompt-box";
16-
17-
const __key = "assistant-early-access-activation";
16+
import { useEarlyAccess } from "@assistant-fp/early-access";
1817

1918
///
2019
/// TODO:
@@ -77,6 +76,7 @@ export function PhotoLoader() {
7776
useState(false);
7877

7978
const [hasMore, setHasMore] = useState(false);
79+
const accesskey = useEarlyAccess();
8080

8181
// load random images on mount, once.
8282
useEffect(() => {
@@ -101,7 +101,6 @@ export function PhotoLoader() {
101101
}
102102
) => {
103103
setLocked(true);
104-
const accesskey = await PluginSdk.getItem(__key);
105104
try {
106105
const { images: gens, n } = await api
107106
.fromGenerative(

yarn.lock

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,12 +1753,7 @@
17531753
resolved "https://registry.yarnpkg.com/@emotion/weak-memoize/-/weak-memoize-0.3.0.tgz#ea89004119dc42db2e1dba0f97d553f7372f6fcb"
17541754
integrity sha512-AHPmaAx+RYfZz0eYu6Gviiagpmiyw98ySSlQvCUhVGDRtDFe4DBS0x1bSjdF3gqUDYOczB+yYvBTtEylYSdRhg==
17551755

1756-
1757-
version "1.37.0"
1758-
resolved "https://registry.yarnpkg.com/@figma/plugin-typings/-/plugin-typings-1.37.0.tgz#0eecf4972db9f321127b519a917ea4b3a40714dd"
1759-
integrity sha512-PfZWzRazevtDp6nfaypxS7jfkbLATTM6dLi0tIJiDvd27vYhX3wBiW1AeTqxtxjBdYY2QV1T34IJYjrOybr5wg==
1760-
1761-
"@figma/plugin-typings@^1.58.0":
1756+
"@figma/[email protected]", "@figma/plugin-typings@^1.58.0":
17621757
version "1.58.0"
17631758
resolved "https://registry.yarnpkg.com/@figma/plugin-typings/-/plugin-typings-1.58.0.tgz#88ae0e57e2ac74203d401f2a70e95e93c470e093"
17641759
integrity sha512-to6hFysqZYACz4VNgaBXflOVS+1pbXGNVcezDmQEMcADDkIZeAZ71Zfqf/B2YDRmU3sM1xX5Q5NkRGhjCuLOLg==
@@ -4280,7 +4275,7 @@
42804275
dependencies:
42814276
"@types/react" "*"
42824277

4283-
"@types/react@*", "@types/react@^18.0.28":
4278+
"@types/react@*", "@types/react@^17.0.14", "@types/react@^18.0.28":
42844279
version "18.0.28"
42854280
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.28.tgz#accaeb8b86f4908057ad629a26635fe641480065"
42864281
integrity sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew==
@@ -4289,15 +4284,6 @@
42894284
"@types/scheduler" "*"
42904285
csstype "^3.0.2"
42914286

4292-
"@types/react@^17.0.14":
4293-
version "17.0.53"
4294-
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.53.tgz#10d4d5999b8af3d6bc6a9369d7eb953da82442ab"
4295-
integrity sha512-1yIpQR2zdYu1Z/dc1OxC+MA6GR240u3gcnP4l6mvj/PJiVaqHsQPmWttsvHsfnhfPbU2FuGmo0wSITPygjBmsw==
4296-
dependencies:
4297-
"@types/prop-types" "*"
4298-
"@types/scheduler" "*"
4299-
csstype "^3.0.2"
4300-
43014287
"@types/scheduler@*":
43024288
version "0.16.2"
43034289
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"
@@ -12425,7 +12411,7 @@ react-use-size@^2.0.4:
1242512411
resolved "https://registry.yarnpkg.com/react-use-size/-/react-use-size-2.0.4.tgz#14f513e310d8962a30919e64fdd746b8211a3f0d"
1242612412
integrity sha512-vMfResvkZwkXngdbytZbDNkDySJqXrEdPa882kTqIQZylxHA6PSf2NC67wJJIMpmZjGyTwV7wyG5YY1SwId1xw==
1242712413

12428-
react@^18.2.0:
12414+
react@18.2.0, react@^18.2.0:
1242912415
version "18.2.0"
1243012416
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
1243112417
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==

0 commit comments

Comments
 (0)