kopia lustrzana https://github.com/elk-zone/elk
				
				
				
			fix: handle permalinks with app shell (#468)
							rodzic
							
								
									f8ebc0e99a
								
							
						
					
					
						commit
						8de1c95fd3
					
				| 
						 | 
				
			
			@ -85,7 +85,7 @@ export async function loginTo(user?: Omit<UserLogin, 'account'> & { account?: Ac
 | 
			
		|||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ('server' in route.params && user?.token) {
 | 
			
		||||
  if ('server' in route.params && user?.token && !useNuxtApp()._processingMiddleware) {
 | 
			
		||||
    await router.push({
 | 
			
		||||
      ...route,
 | 
			
		||||
      force: true,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,7 @@
 | 
			
		|||
export default defineNuxtRouteMiddleware(async (to, from) => {
 | 
			
		||||
  if (process.server)
 | 
			
		||||
    return
 | 
			
		||||
 | 
			
		||||
  // Skip running middleware before masto has been initialised
 | 
			
		||||
  if (!useNuxtApp().$masto)
 | 
			
		||||
    return
 | 
			
		||||
| 
						 | 
				
			
			@ -44,8 +47,12 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
 | 
			
		|||
        return getAccountRoute(account)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const masto = useMasto()
 | 
			
		||||
    if (!masto.loggedIn.value)
 | 
			
		||||
      await masto.loginTo(currentUser.value)
 | 
			
		||||
 | 
			
		||||
    // If we're logged in, search for the local id the account or status corresponds to
 | 
			
		||||
    const { value } = await useMasto().search({ q: `https:/${to.fullPath}`, resolve: true, limit: 1 }).next()
 | 
			
		||||
    const { value } = await masto.search({ q: `https:/${to.fullPath}`, resolve: true, limit: 1 }).next()
 | 
			
		||||
 | 
			
		||||
    const { accounts, statuses } = value
 | 
			
		||||
    if (statuses[0])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,7 +53,8 @@ export default defineNuxtPlugin(async (nuxtApp) => {
 | 
			
		|||
 | 
			
		||||
    nuxtApp.hook('app:suspense:resolve', () => {
 | 
			
		||||
      // TODO: improve upstream to make this synchronous (delayed auth)
 | 
			
		||||
      masto.loginTo(user)
 | 
			
		||||
      if (!masto.loggedIn.value)
 | 
			
		||||
        masto.loginTo(user)
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue