Skip to content

Commit bd56c14

Browse files
committed
fix unsupported redirects
1 parent 48767c3 commit bd56c14

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

apps/gui/src/lib/components/blocks/Header.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
import { doBootstrap } from '$lib/stores/routines';
55
import { hasBeenBoostrapped } from '$lib/stores/app';
66
import { totalMonitors } from '$lib/stores';
7+
import { unsupported } from '$lib/stores/app';
78
89
$: isHomepage = $page.url.pathname === '/';
910
$: isBootstrapped = hasBeenBoostrapped();
1011
$: loadedEnough = hasBeenBoostrapped() || $totalMonitors.size > 1
1112
</script>
1213

1314
<header id="site-header">
14-
15+
{#if (loadedEnough || !$doBootstrap) && !$unsupported}
1516
<h1>nostr.watch</h1>
16-
{#if loadedEnough || !$doBootstrap}
1717
<nav>
1818
<a href="/">home</a>
1919
<a href="/relays">relays</a>
2020
<a href="/monitors">monitors</a>
2121
<a href="/preferences">preferences</a>
2222
</nav>
2323
{/if}
24-
{#if !isHomepage}
24+
{#if !isHomepage && (loadedEnough || !$doBootstrap) && !$unsupported}
2525
<div class="search-container">
2626
<search>
2727
<AutoSuggestRelays />

apps/gui/src/lib/stores/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { readable, writable, derived, get } from "svelte/store";
44
import { formatSeconds, timeAgo } from "../utils/time";
55

66

7+
export const unsupported: Writable<boolean> = writable(false)
78
export const isLivesyncing: Writable<boolean> = writable(false)
89
export const isBootstrapping: Writable<boolean> = writable(false)
910
export const lastCompleteSync: Writable<number> = writable(StateManager.get('lastCompleteSync') ?? 0)

apps/gui/src/routes/+layout.svelte

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ import { destroy } from '$lib/utils/lifecycle';
1515
import { createTabLifecycle } from '$lib/utils/tab-lifecycle';
1616
import { delay } from '@nostrwatch/utils';
1717
import { getBrowserInfo } from '$lib/utils/compat.js';
18-
import { StateManager } from '@nostrwatch/nip66';
18+
import { StateManager } from '@nostrwatch/nip66';
19+
import { unsupported } from '$lib/stores/app';
1920
2021
const isLeader: Writable<boolean> = writable(false);
2122
2223
const lifecycle = createTabLifecycle();
2324
2425
lifecycle.onStartLeader(async () => {
2526
isLeader.set(true);
27+
if($unsupported) return;
2628
await loadData();
2729
console.log('Leader tab: DB initialized.');
2830
});
@@ -48,6 +50,7 @@ lifecycle.onWaitForLeaderRelease(() => {
4850
lifecycle.onLeaderAcquired(async () => {
4951
console.log('Non-leader tab: Just became leader, initializing DB.');
5052
isLeader.set(true);
53+
if($unsupported) return;
5154
await loadData();
5255
});
5356
@@ -81,21 +84,27 @@ const loadData = async () => {
8184
}
8285
}
8386
84-
onDestroy(unsubscribe);
87+
const checkSupport = () => {
88+
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
89+
const isMobile = /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|Mobile/i.test(userAgent);
90+
const isSafari = getBrowserInfo()?.name.toLowerCase().includes('safari')
8591
86-
onMount(async () => {
87-
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
88-
const isMobile = /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|Mobile/i.test(userAgent);
89-
const isSafari = getBrowserInfo()?.name.toLowerCase().includes('safari')
92+
unsupported.set(isSafari || isMobile)
9093
91-
if (isMobile && $page.url.pathname !== '/mobile') {
92-
goto('/mobile');
93-
}
94+
if (isMobile && $page.url.pathname !== '/mobile') {
95+
goto('/mobile');
96+
}
9497
95-
if(isSafari && $page.url.pathname !== '/unsupported') {
96-
goto('/unsupported');
97-
}
98+
if(isSafari && $page.url.pathname !== '/unsupported') {
99+
goto('/unsupported');
100+
}
101+
}
102+
103+
onDestroy(unsubscribe);
98104
105+
onMount(async () => {
106+
107+
checkSupport()
99108
100109
const version = StateManager.get('version')
101110
if(!version || version !== 2) { //TODO NEED A LOCAL STORAGE SCHEMA VERFSIONING SYSTEM!!!
@@ -116,6 +125,7 @@ onMount(async () => {
116125
117126
$effect(() => {
118127
if ($navigating) {
128+
checkSupport();
119129
loadData();
120130
}
121131
});

libraries/nip66/src/services/MonitorService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,8 @@ export class MonitorService extends Service {
602602

603603

604604
async modifyReturnedEvents(events: IEvent[]): Promise<IEvent[]> {
605-
// return events;
606-
return this.removeStaleChecks(events);
605+
return events;
606+
// return this.removeStaleChecks(events);
607607
}
608608

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

0 commit comments

Comments
 (0)