export default defineNuxtRouteMiddleware(async (to, from) => {
  if (import.meta.dev || import.meta.server)
    return

  const { isTauri } = useApp()

  if (!isTauri.value)
    return

  if (from?.name || !!to.redirectedFrom)
    return

  const { checkForUpdates } = useUpdater()

  const update = await checkForUpdates()

  if (update) {
    return navigateTo({ name: 'Updater' })
  }
})
