Skip to content

Commit

Permalink
fix unsupported redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Dec 19, 2024
1 parent 48767c3 commit bd56c14
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
6 changes: 3 additions & 3 deletions apps/gui/src/lib/components/blocks/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
import { doBootstrap } from '$lib/stores/routines';
import { hasBeenBoostrapped } from '$lib/stores/app';
import { totalMonitors } from '$lib/stores';
import { unsupported } from '$lib/stores/app';
$: isHomepage = $page.url.pathname === '/';
$: isBootstrapped = hasBeenBoostrapped();
$: loadedEnough = hasBeenBoostrapped() || $totalMonitors.size > 1
</script>

<header id="site-header">

{#if (loadedEnough || !$doBootstrap) && !$unsupported}
<h1>nostr.watch</h1>
{#if loadedEnough || !$doBootstrap}
<nav>
<a href="/">home</a>
<a href="/relays">relays</a>
<a href="/monitors">monitors</a>
<a href="/preferences">preferences</a>
</nav>
{/if}
{#if !isHomepage}
{#if !isHomepage && (loadedEnough || !$doBootstrap) && !$unsupported}
<div class="search-container">
<search>
<AutoSuggestRelays />
Expand Down
1 change: 1 addition & 0 deletions apps/gui/src/lib/stores/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { readable, writable, derived, get } from "svelte/store";
import { formatSeconds, timeAgo } from "../utils/time";


export const unsupported: Writable<boolean> = writable(false)
export const isLivesyncing: Writable<boolean> = writable(false)
export const isBootstrapping: Writable<boolean> = writable(false)
export const lastCompleteSync: Writable<number> = writable(StateManager.get('lastCompleteSync') ?? 0)
Expand Down
34 changes: 22 additions & 12 deletions apps/gui/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ import { destroy } from '$lib/utils/lifecycle';
import { createTabLifecycle } from '$lib/utils/tab-lifecycle';
import { delay } from '@nostrwatch/utils';
import { getBrowserInfo } from '$lib/utils/compat.js';
import { StateManager } from '@nostrwatch/nip66';
import { StateManager } from '@nostrwatch/nip66';
import { unsupported } from '$lib/stores/app';
const isLeader: Writable<boolean> = writable(false);
const lifecycle = createTabLifecycle();
lifecycle.onStartLeader(async () => {
isLeader.set(true);
if($unsupported) return;
await loadData();
console.log('Leader tab: DB initialized.');
});
Expand All @@ -48,6 +50,7 @@ lifecycle.onWaitForLeaderRelease(() => {
lifecycle.onLeaderAcquired(async () => {
console.log('Non-leader tab: Just became leader, initializing DB.');
isLeader.set(true);
if($unsupported) return;
await loadData();
});
Expand Down Expand Up @@ -81,21 +84,27 @@ const loadData = async () => {
}
}
onDestroy(unsubscribe);
const checkSupport = () => {
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
const isMobile = /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|Mobile/i.test(userAgent);
const isSafari = getBrowserInfo()?.name.toLowerCase().includes('safari')
onMount(async () => {
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
const isMobile = /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|Mobile/i.test(userAgent);
const isSafari = getBrowserInfo()?.name.toLowerCase().includes('safari')
unsupported.set(isSafari || isMobile)
if (isMobile && $page.url.pathname !== '/mobile') {
goto('/mobile');
}
if (isMobile && $page.url.pathname !== '/mobile') {
goto('/mobile');
}
if(isSafari && $page.url.pathname !== '/unsupported') {
goto('/unsupported');
}
if(isSafari && $page.url.pathname !== '/unsupported') {
goto('/unsupported');
}
}
onDestroy(unsubscribe);
onMount(async () => {
checkSupport()
const version = StateManager.get('version')
if(!version || version !== 2) { //TODO NEED A LOCAL STORAGE SCHEMA VERFSIONING SYSTEM!!!
Expand All @@ -116,6 +125,7 @@ onMount(async () => {
$effect(() => {
if ($navigating) {
checkSupport();
loadData();
}
});
Expand Down
4 changes: 2 additions & 2 deletions libraries/nip66/src/services/MonitorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ export class MonitorService extends Service {


async modifyReturnedEvents(events: IEvent[]): Promise<IEvent[]> {
// return events;
return this.removeStaleChecks(events);
return events;
// return this.removeStaleChecks(events);
}

async removeStaleChecks(events: IEvent[]): Promise<IEvent[]> {
Expand Down

0 comments on commit bd56c14

Please sign in to comment.