From da7aef454804acb02d37551e586dd3b08feadeb3 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Wed, 6 May 2026 00:32:15 +0200 Subject: [PATCH] fix(profiles): avoid placeholder profile on first launch --- lib/connection/connection_bootstrap.dart | 23 ------------------- .../connection/connection_bootstrap_test.dart | 8 +++++++ 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/lib/connection/connection_bootstrap.dart b/lib/connection/connection_bootstrap.dart index 0f16172f..5079666b 100644 --- a/lib/connection/connection_bootstrap.dart +++ b/lib/connection/connection_bootstrap.dart @@ -1,7 +1,5 @@ import 'dart:convert'; -import 'package:uuid/uuid.dart'; - import '../models/plex/plex_home.dart'; import '../models/plex/plex_home_user.dart'; import '../profiles/profile.dart'; @@ -41,7 +39,6 @@ class ConnectionBootstrap { final Future> Function(String accountToken) _plexUserInfoFetcher; static const String _keyProfileMigrationV1Done = 'profile_migration_v1_done'; - static const String _ownerProfileIdPrefix = 'local-'; /// Run all idempotent boot-time migrations. Best-effort — errors are /// logged but never thrown. @@ -70,7 +67,6 @@ class ConnectionBootstrap { return; } } - await _ensureOwnerProfile(); if (hadLegacyPlexToken) { await storage.clearLegacyPlexToken(); } @@ -271,25 +267,6 @@ class ConnectionBootstrap { } } - /// Make sure fresh non-Plex installs always have at least one local profile. - /// Migrated Plex accounts select a virtual Plex Home profile instead. - Future _ensureOwnerProfile() async { - final existing = await profileRegistry.list(); - if (existing.isNotEmpty) return; - if (storage.getActiveProfileId() != null) return; - - final owner = Profile( - id: '$_ownerProfileIdPrefix${const Uuid().v4()}', - kind: ProfileKind.local, - displayName: 'Default', - sortOrder: 0, - createdAt: DateTime.now(), - ); - await profileRegistry.upsert(owner); - await storage.setActiveProfileId(owner.id); - appLogger.i('Migration: created placeholder Default profile (no Plex account on first launch)'); - } - Future _firstPlexAccount(PlexAccountConnection? preferred) async { if (preferred != null) return preferred; final connections = await connectionRegistry.list(); diff --git a/test/connection/connection_bootstrap_test.dart b/test/connection/connection_bootstrap_test.dart index 7da48604..dab73932 100644 --- a/test/connection/connection_bootstrap_test.dart +++ b/test/connection/connection_bootstrap_test.dart @@ -47,6 +47,14 @@ void main() { }); group('ConnectionBootstrap.migrateLegacyPlexAccount', () { + test('run leaves fresh installs without a placeholder local profile', () async { + await bootstrap.run(); + + expect(await profileRegistry.list(), isEmpty); + expect(storage.getActiveProfileId(), isNull); + expect(storage.prefs.getBool('profile_migration_v1_done'), isTrue); + }); + test('returns null when no legacy Plex token is stored', () async { final result = await bootstrap.migrateLegacyPlexAccount(); expect(result, isNull);