Skip to content

Commit

Permalink
v8.1.11 sockdrive premium users
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Jun 26, 2024
1 parent abeb485 commit ca5b9e3
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-dos",
"version": "8.1.10",
"version": "8.1.11",
"description": "Full-featured DOS player with multiple emulator backends",
"type": "module",
"keywords": [
Expand Down
5 changes: 2 additions & 3 deletions src/components/dos-option-checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,14 @@ export function SockdriveWrite() {
const t = useT();
const dispatch = useDispatch();
const account = useSelector((state: State) => state.auth.account);
const premium = account?.premium === true;
const visible = useSelector((state: State) => state.dos.backend === "dosboxX");
const checked = useSelector((state: State) => state.dos.sockdriveWrite) && premium;
const checked = useSelector((state: State) => state.dos.sockdriveWrite) && account !== null;
return visible ? <Checkbox
class="mt-4"
label={t("fat_write")}
checked={checked}
onChange={(c) => {
if (!premium) {
if (!account) {
dispatchLoginAction(account, dispatch);
} else {
dispatch(dosSlice.actions.setSockdriveWrite(c));
Expand Down
2 changes: 1 addition & 1 deletion src/frame/account-frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function PremiumPlan(props: {}) {

return <div class={"premium-plan-root " + (account.premium ? "have-premium" : "")}>
<div class="premium-plan-head flex">
<PremiumCheck />
{ account.premium && <PremiumCheck /> }
{t("premium")}
<div class="flex-grow"></div>
{account.premium &&
Expand Down
18 changes: 14 additions & 4 deletions src/frame/fat-drives-frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export function FatDrivesFrame() {
sockdriveBackend["js-dos"]);
const [myDrives, setMyDrives] = useState<Drive[]>([]);
const dispatch = useDispatch();
const preimium = account?.premium ?? false;
const me = account?.email ?? "";
const [filter, setFilter] = useState<string>("");
const [busy, setBusy] = useState<boolean>(true);
Expand All @@ -32,6 +31,8 @@ export function FatDrivesFrame() {
const [deleteConfirm, setDeleteConfirm] = useState<string>("");
const [dialogError, setDialogError] = useState<string | null>(null);
const [dialogIndex, setDialogIndex] = useState<number>(-1);
const [sockdrivePremium, setSockdrivePremium] = useState<boolean>(false);
const premium = (account?.premium ?? false) || sockdrivePremium;


function reloadDrives() {
Expand Down Expand Up @@ -88,11 +89,20 @@ export function FatDrivesFrame() {
fetch(sockdriveEndpoint + "/list/drives/" + account.token.access_token)
.then((r) => r.json())
.then((drives: Drive[]) => {
console.log(JSON.stringify(drives, null, 2));
setMyDrives(drives.sort((a, b) => a.name.localeCompare(b.name)));
})
.catch(console.error)
.finally(() => setBusy(false));

fetch(sockdriveEndpoint + "/premium/" + account.email)
.then((r) => r.json())
.then((payload: { premium: boolean }) => {
setSockdrivePremium(payload.premium);
})
.catch((e) => {
console.error(e);
setSockdrivePremium(false);
});
}
}

Expand Down Expand Up @@ -132,7 +142,7 @@ export function FatDrivesFrame() {
{owner !== account?.email &&
<p class="text-xs">{owner}</p>}
</td>
{preimium && <td>
{premium && <td>
{account?.token && <div class="btn btn-ghost btn-xs"
onClick={() => {
setDialogIndex(index);
Expand All @@ -144,7 +154,7 @@ export function FatDrivesFrame() {
deleteDialogRef.current?.showModal();
}}>{t("delete")}</div>}
</td>}
{!preimium && <td>
{!premium && <td>
<div class="cursor-pointer"
onClick={() => dispatchLoginAction(account, dispatch)}>
<LockBadge class="text-error" />
Expand Down
8 changes: 4 additions & 4 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const translations: {[lang: string]: {[key: string]: string} } = {
logout: "Выйти",
please_login: "Войдите в аккаунт",
features: "Функции",
premium: "Премиум",
premium: "Подписка",
buy: "Купить",
experimental_features: "Доступ к экспериентальным функциям",
cloud_saves: "Облачные сохранения",
Expand Down Expand Up @@ -62,7 +62,7 @@ const translations: {[lang: string]: {[key: string]: string} } = {
loading_saves: "Загрузка сохранений",
success: "Успешно",
unable_to_save: "Ошибка записи",
not_premium: "Подключить премиум",
not_premium: "Подключить подписку",
copy_net_link: "Отправьте ссылку на подключение",
copied: "Скопировано",
image_rendering: "Обработка изображения",
Expand All @@ -87,7 +87,7 @@ const translations: {[lang: string]: {[key: string]: string} } = {
logout: "Logout",
please_login: "Please login",
features: "Features",
premium: "Premium",
premium: "Subscription",
buy: "Buy",
experimental_features: "Access to all experimental features",
cloud_saves: "Cloud saves",
Expand Down Expand Up @@ -136,7 +136,7 @@ const translations: {[lang: string]: {[key: string]: string} } = {
loading_saves: "Loading saves",
success: "Success",
unable_to_save: "Unable to save",
not_premium: "Subscribe to premium",
not_premium: "Subscribe",
copy_net_link: "Share this link to connect",
copied: "Copied",
image_rendering: "Image rendering",
Expand Down
3 changes: 1 addition & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export const Dos: DosFn = (element: HTMLDivElement,
const store = makeStore(nonSerializableStore, options);


if (store.getState().auth.account?.email === "[email protected]" ||
store.getState().auth.account?.email === "[email protected]") {
if (store.getState().auth.account?.email === "[email protected]") {
store.dispatch(dosSlice.actions.setSockdriveWrite(false));
}

Expand Down
6 changes: 2 additions & 4 deletions src/store/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ export const authSlice = createSlice({
setRefreshToken(action.payload.token.refresh_token);
state.account = action.payload;
state.account.premium = state.account.premium ||
state.account.email === "[email protected]" ||
state.account.email === "[email protected]";
state.account.email === "[email protected]";
lStorage.setItem(cachedAccount, JSON.stringify(action.payload));
(action as unknown as DosAction).asyncStore((store) => {
if (action.payload.email === "[email protected]" ||
action.payload.email === "[email protected]") {
if (action.payload.email === "[email protected]") {
store.dispatch(dosSlice.actions.setSockdriveWrite(false));
}
getCache(action.payload.email)
Expand Down

0 comments on commit ca5b9e3

Please sign in to comment.