(threadId: string)
| 289 | } |
| 290 | |
| 291 | async function selectThread(threadId: string) { |
| 292 | const text = getSelectedText(); |
| 293 | if (text) { |
| 294 | return null; |
| 295 | } |
| 296 | const currentThread = |
| 297 | threads.find((t) => t.id === threadId) || |
| 298 | pinnedThreads.find((t) => t.id === threadId); |
| 299 | |
| 300 | if (!currentThread) { |
| 301 | return; |
| 302 | } |
| 303 | setCollapsed(true); |
| 304 | onSelectThread(currentThread.id); |
| 305 | const url = getThreadUrl({ |
| 306 | isSubDomainRouting, |
| 307 | settings, |
| 308 | incrementId: currentThread.incrementId, |
| 309 | slug: currentThread.slug, |
| 310 | LINEN_URL: |
| 311 | process.env.NODE_ENV === 'development' |
| 312 | ? 'http://localhost:3000' |
| 313 | : 'https://www.linen.dev', |
| 314 | }); |
| 315 | window.history.pushState( |
| 316 | { |
| 317 | ...window.history.state, |
| 318 | options: { |
| 319 | ...window.history.state.options, |
| 320 | _preventNextJSReload: false, |
| 321 | }, |
| 322 | }, |
| 323 | '', |
| 324 | url |
| 325 | ); |
| 326 | window.onpopstate = (event) => { |
| 327 | event.preventDefault(); |
| 328 | window.history.pushState( |
| 329 | { |
| 330 | ...window.history.state, |
| 331 | options: { |
| 332 | ...window.history.state.options, |
| 333 | _preventNextJSReload: true, |
| 334 | }, |
| 335 | }, |
| 336 | '', |
| 337 | window.history.state.url |
| 338 | ); |
| 339 | setCollapsed(false); |
| 340 | onSelectThread(undefined); |
| 341 | }; |
| 342 | } |
| 343 | |
| 344 | const rootMargin = |
| 345 | viewport === 'desktop' ? '640px 0px 640px 0px' : '0px 0px 0px 0px'; |
no test coverage detected