blob: 47acb6ea2ab319783184e6832288f30654cb418d [file]
import 'package:archive/archive.dart';
import '../data/project_store.dart' show ProjectStore;
const _sentinel = Object();
class PersistedProject {
const PersistedProject({
required this.id,
required this.name,
required this.createdAt,
required this.updatedAt,
required this.lastOpenedAt,
this.archive,
});
final String id;
final String? name;
final DateTime createdAt;
final DateTime updatedAt;
final DateTime lastOpenedAt;
/// The project's file archive. This is `null` when the project was loaded
/// as metadata-only (e.g. from [ProjectStore.listProjects]).
final Archive? archive;
/// Copies a project while allowing [name] to be explicitly set to `null`.
///
/// A private sentinel distinguishes "do not change the name" from "clear the
/// name", which is needed while prompt-created projects wait for title
/// generation.
PersistedProject copyWith({
Object? name = _sentinel,
DateTime? updatedAt,
DateTime? lastOpenedAt,
Object? archive = _sentinel,
}) {
return PersistedProject(
id: id,
name: name == _sentinel ? this.name : name as String?,
createdAt: createdAt,
updatedAt: updatedAt ?? this.updatedAt,
lastOpenedAt: lastOpenedAt ?? this.lastOpenedAt,
archive: archive == _sentinel ? this.archive : archive as Archive?,
);
}
}