mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(thread-page): make thread auto updates opt-in (#1115)
* fix(thread-page): make thread auto updates opt-in Wire `Auto` and `Update` to the same manual refresh path and cover the thread flow with an e2e harness. * fix(thread-page): address PR review findings
This commit is contained in:
+24
-9
@@ -16,21 +16,36 @@ import { Analytics } from '@vercel/analytics/react';
|
||||
const isVercelDeployment =
|
||||
typeof window !== 'undefined' && (window.location.hostname === '5chan.app' || window.location.hostname === 'www.5chan.app') && !window.isElectron;
|
||||
const e2eStartHash = import.meta.env.VITE_E2E_START_HASH?.trim();
|
||||
const shouldRenderThreadAutoUpdateHarness =
|
||||
import.meta.env.DEV && typeof window !== 'undefined' && new URLSearchParams(window.location.search).get('e2e') === 'thread-auto-update';
|
||||
|
||||
if (typeof window !== 'undefined' && e2eStartHash && window.location.hash.length === 0) {
|
||||
window.location.hash = e2eStartHash.startsWith('#') ? e2eStartHash : `#${e2eStartHash}`;
|
||||
}
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<Router>
|
||||
<AppUpdateRegistration />
|
||||
<App />
|
||||
{isVercelDeployment && <Analytics />}
|
||||
</Router>
|
||||
</React.StrictMode>,
|
||||
);
|
||||
const renderRoot = async () => {
|
||||
let threadAutoUpdateHarness: React.ComponentType | null = null;
|
||||
if (shouldRenderThreadAutoUpdateHarness) {
|
||||
threadAutoUpdateHarness = (await import('./e2e/thread-auto-update-harness')).default;
|
||||
}
|
||||
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
{threadAutoUpdateHarness ? (
|
||||
React.createElement(threadAutoUpdateHarness)
|
||||
) : (
|
||||
<Router>
|
||||
<AppUpdateRegistration />
|
||||
<App />
|
||||
{isVercelDeployment && <Analytics />}
|
||||
</Router>
|
||||
)}
|
||||
</React.StrictMode>,
|
||||
);
|
||||
};
|
||||
|
||||
void renderRoot();
|
||||
|
||||
// add back button in android app
|
||||
CapacitorApp.addListener('backButton', ({ canGoBack }) => {
|
||||
|
||||
Reference in New Issue
Block a user