mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2026-02-11 17:24:25 +01:00
add pwa detection
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { createResource, Show, onMount } from "solid-js";
|
||||
import { createResource, Show } from "solid-js";
|
||||
|
||||
const relayUrls = [
|
||||
"wss://nostr.zebedee.cloud",
|
||||
@@ -33,16 +33,6 @@ const postsFetcher = async () => {
|
||||
export function WaitlistAlreadyIn() {
|
||||
const [posts] = createResource("", postsFetcher);
|
||||
|
||||
// Allow invite parameter to bypass waitlist
|
||||
onMount(() => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const invite = urlParams.get('invite');
|
||||
if (invite === 'true') {
|
||||
localStorage.setItem('already_approved', 'true');
|
||||
window.location.href = "/";
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<main class="flex flex-col gap-4 sm:gap-4 py-8 px-4 max-w-xl mx-auto items-start drop-shadow-blue-glow">
|
||||
<a href="https://mutinywallet.com">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Match, Switch, createSignal, onMount } from "solid-js";
|
||||
import { Match, Switch, createSignal } from "solid-js";
|
||||
import { Button } from "~/components/layout";
|
||||
import { StyledRadioGroup } from "../layout/Radio";
|
||||
import { TextField } from "../layout/TextField";
|
||||
@@ -37,16 +37,6 @@ export default function WaitlistForm() {
|
||||
|
||||
const [loading, setLoading] = createSignal(false);
|
||||
|
||||
// Allow invite parameter to bypass waitlist
|
||||
onMount(() => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const invite = urlParams.get('invite');
|
||||
if (invite === 'true') {
|
||||
localStorage.setItem('already_approved', 'true');
|
||||
window.location.href = "/";
|
||||
}
|
||||
});
|
||||
|
||||
const newHandleSubmit: SubmitHandler<WaitlistForm> = async (
|
||||
f: WaitlistForm
|
||||
) => {
|
||||
|
||||
@@ -46,6 +46,7 @@ export type MegaStore = [
|
||||
nwc_enabled: boolean;
|
||||
activity: MutinyActivity[];
|
||||
setup_error?: Error;
|
||||
is_pwa: boolean;
|
||||
},
|
||||
{
|
||||
fetchUserStatus(): Promise<UserStatus>;
|
||||
@@ -83,7 +84,8 @@ export const Provider: ParentComponent = (props) => {
|
||||
wallet_loading: true,
|
||||
nwc_enabled: localStorage.getItem("nwc_enabled") === "true",
|
||||
activity: [] as MutinyActivity[],
|
||||
setup_error: undefined as Error | undefined
|
||||
setup_error: undefined as Error | undefined,
|
||||
is_pwa: window.matchMedia("(display-mode: standalone)").matches
|
||||
});
|
||||
|
||||
const actions = {
|
||||
@@ -93,6 +95,20 @@ export const Provider: ParentComponent = (props) => {
|
||||
return "approved";
|
||||
}
|
||||
|
||||
// Using a PWA
|
||||
if (state.is_pwa) {
|
||||
localStorage.setItem("already_approved", "true");
|
||||
return "approved";
|
||||
}
|
||||
|
||||
// Got an invite link
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const invite = urlParams.get("invite");
|
||||
if (invite === "true") {
|
||||
localStorage.setItem("already_approved", "true");
|
||||
return "approved";
|
||||
}
|
||||
|
||||
if (!state.waitlist_id) {
|
||||
return "new_here";
|
||||
}
|
||||
|
||||
@@ -6,37 +6,37 @@ import wasm from "vite-plugin-wasm";
|
||||
import * as path from 'path'
|
||||
|
||||
const pwaOptions: Partial<VitePWAOptions> = {
|
||||
base: '/',
|
||||
registerType: "autoUpdate",
|
||||
devOptions: {
|
||||
enabled: false
|
||||
},
|
||||
includeAssets: ['favicon.ico', 'robots.txt'],
|
||||
manifest: {
|
||||
name: 'Mutiny Wallet',
|
||||
short_name: 'Mutiny',
|
||||
description: 'A lightning wallet',
|
||||
theme_color: '#000',
|
||||
icons: [
|
||||
{
|
||||
src: '192.png',
|
||||
sizes: '192x192',
|
||||
type: 'image/png'
|
||||
},
|
||||
{
|
||||
src: '512.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png'
|
||||
},
|
||||
{
|
||||
src: 'maskable_icon.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png',
|
||||
purpose: 'any maskable'
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
base: "/",
|
||||
registerType: "autoUpdate",
|
||||
devOptions: {
|
||||
enabled: false
|
||||
},
|
||||
includeAssets: ["favicon.ico", "robots.txt"],
|
||||
manifest: {
|
||||
name: "Mutiny Wallet",
|
||||
short_name: "Mutiny",
|
||||
description: "A lightning wallet",
|
||||
theme_color: "#000",
|
||||
icons: [
|
||||
{
|
||||
src: "192.png",
|
||||
sizes: "192x192",
|
||||
type: "image/png"
|
||||
},
|
||||
{
|
||||
src: "512.png",
|
||||
sizes: "512x512",
|
||||
type: "image/png"
|
||||
},
|
||||
{
|
||||
src: "maskable_icon.png",
|
||||
sizes: "512x512",
|
||||
type: "image/png",
|
||||
purpose: "any maskable"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
|
||||
Reference in New Issue
Block a user