hasUpdate static method

Future<bool> hasUpdate()

Whether the server holds a build other than the one this tab is running.

Implementation

static Future<bool> hasUpdate() async {
  if (!UApp.isWeb) return false;
  if (await UWebBridge.serviceWorkerHasPendingUpdate().timeout(timeout, onTimeout: () => false)) return true;

  final UWebBuild? server = await serverBuild();
  if (server == null) return false;

  // Compiled-in id versus the deployed one: exact, and blind to how anything is cached.
  if (buildId.isNotEmpty && server.id.isNotEmpty) return buildId != server.id;

  // A service worker still caching assets pins the tab to its own generation.
  final String? running = runningServiceWorkerVersion();
  if (running != null && server.serviceWorkerVersion != null) return running != server.serviceWorkerVersion;

  // Last resort: the entry point the browser has on disk versus the one on the server.
  final UWebBuild? cached = await cachedBuild();
  return cached != null && cached.signature != server.signature;
}