feat(03-01): add timestamp field to OverlayMessage model
- Add timestamp field with auto-population via DateTime.now() - Update all factory constructors to include timestamp - Serialize timestamp as millisecondsSinceEpoch in toMap() - Deserialize with fallback to DateTime.now() in fromMap() - Add timestamp parameter to copyWith() method - Remove const modifiers to allow DateTime.now() runtime values Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,8 +10,9 @@ class OverlayMessage {
|
|||||||
final int? themeIndex;
|
final int? themeIndex;
|
||||||
final double? overlayWidth;
|
final double? overlayWidth;
|
||||||
final double? overlayHeight;
|
final double? overlayHeight;
|
||||||
|
final DateTime timestamp;
|
||||||
|
|
||||||
const OverlayMessage({
|
OverlayMessage({
|
||||||
required this.action,
|
required this.action,
|
||||||
this.speedText,
|
this.speedText,
|
||||||
this.unitText,
|
this.unitText,
|
||||||
@@ -21,6 +22,7 @@ class OverlayMessage {
|
|||||||
this.themeIndex,
|
this.themeIndex,
|
||||||
this.overlayWidth,
|
this.overlayWidth,
|
||||||
this.overlayHeight,
|
this.overlayHeight,
|
||||||
|
required this.timestamp,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Factory constructor for display update messages
|
/// Factory constructor for display update messages
|
||||||
@@ -44,17 +46,24 @@ class OverlayMessage {
|
|||||||
themeIndex: themeIndex,
|
themeIndex: themeIndex,
|
||||||
overlayWidth: overlayWidth,
|
overlayWidth: overlayWidth,
|
||||||
overlayHeight: overlayHeight,
|
overlayHeight: overlayHeight,
|
||||||
|
timestamp: DateTime.now(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Factory constructor for long press close signal
|
/// Factory constructor for long press close signal
|
||||||
factory OverlayMessage.longPressClose() {
|
factory OverlayMessage.longPressClose() {
|
||||||
return const OverlayMessage(action: 'longPressClose');
|
return OverlayMessage(
|
||||||
|
action: 'longPressClose',
|
||||||
|
timestamp: DateTime.now(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Factory constructor for overlay closed notification
|
/// Factory constructor for overlay closed notification
|
||||||
factory OverlayMessage.overlayClosed() {
|
factory OverlayMessage.overlayClosed() {
|
||||||
return const OverlayMessage(action: 'overlayClosed');
|
return OverlayMessage(
|
||||||
|
action: 'overlayClosed',
|
||||||
|
timestamp: DateTime.now(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Serialize to Map for overlay IPC
|
/// Serialize to Map for overlay IPC
|
||||||
@@ -68,6 +77,7 @@ class OverlayMessage {
|
|||||||
if (themeIndex != null) map['themeIndex'] = themeIndex;
|
if (themeIndex != null) map['themeIndex'] = themeIndex;
|
||||||
if (overlayWidth != null) map['overlayWidth'] = overlayWidth;
|
if (overlayWidth != null) map['overlayWidth'] = overlayWidth;
|
||||||
if (overlayHeight != null) map['overlayHeight'] = overlayHeight;
|
if (overlayHeight != null) map['overlayHeight'] = overlayHeight;
|
||||||
|
map['timestamp'] = timestamp.millisecondsSinceEpoch;
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +93,9 @@ class OverlayMessage {
|
|||||||
themeIndex: map['themeIndex'] as int?,
|
themeIndex: map['themeIndex'] as int?,
|
||||||
overlayWidth: (map['overlayWidth'] as num?)?.toDouble(),
|
overlayWidth: (map['overlayWidth'] as num?)?.toDouble(),
|
||||||
overlayHeight: (map['overlayHeight'] as num?)?.toDouble(),
|
overlayHeight: (map['overlayHeight'] as num?)?.toDouble(),
|
||||||
|
timestamp: DateTime.fromMillisecondsSinceEpoch(
|
||||||
|
map['timestamp'] as int? ?? DateTime.now().millisecondsSinceEpoch,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +110,7 @@ class OverlayMessage {
|
|||||||
int? themeIndex,
|
int? themeIndex,
|
||||||
double? overlayWidth,
|
double? overlayWidth,
|
||||||
double? overlayHeight,
|
double? overlayHeight,
|
||||||
|
DateTime? timestamp,
|
||||||
}) {
|
}) {
|
||||||
return OverlayMessage(
|
return OverlayMessage(
|
||||||
action: action ?? this.action,
|
action: action ?? this.action,
|
||||||
@@ -108,6 +122,7 @@ class OverlayMessage {
|
|||||||
themeIndex: themeIndex ?? this.themeIndex,
|
themeIndex: themeIndex ?? this.themeIndex,
|
||||||
overlayWidth: overlayWidth ?? this.overlayWidth,
|
overlayWidth: overlayWidth ?? this.overlayWidth,
|
||||||
overlayHeight: overlayHeight ?? this.overlayHeight,
|
overlayHeight: overlayHeight ?? this.overlayHeight,
|
||||||
|
timestamp: timestamp ?? this.timestamp,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user