add option to show timestamps on historical messages

Defaults to off so historical messages now respect the global timestamp
setting instead of forcing a locale-based timestamp when timestamps are
disabled.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tommy Chow 2026-04-18 14:53:55 -07:00
parent 0631ac562e
commit 12c2fed7da
5 changed files with 64 additions and 9 deletions

View file

@ -664,6 +664,7 @@ class IRCMessage {
Map<String, UserTwitch>? channelIdToUserTwitch,
TimestampType timestamp = TimestampType.disabled,
bool forceTimestamp = false,
bool showHistoricalTimestamps = false,
String? currentChannelId,
}) {
final emoteToObject = assetsStore.emoteToObject;
@ -674,11 +675,13 @@ class IRCMessage {
// The span list that will be used to render the chat message
final span = <InlineSpan>[];
// Always show timestamps on historical messages, falling back to the
// device's locale preference when the user has timestamps disabled.
// When the user has timestamps disabled globally, fall back to the device's
// locale preference for historical messages (opt-in via setting) and for
// forced contexts like previews.
final isHistorical = tags['historical'] == '1';
final effectiveTimestamp =
(timestamp == TimestampType.disabled && (isHistorical || forceTimestamp))
(timestamp == TimestampType.disabled &&
((isHistorical && showHistoricalTimestamps) || forceTimestamp))
? (MediaQuery.alwaysUse24HourFormatOf(context)
? TimestampType.twentyFour
: TimestampType.twelve)

View file

@ -129,7 +129,10 @@ class ChatMessage extends StatelessWidget {
launchExternal: chatStore.settings.launchUrlExternal,
timestamp: chatStore.settings.timestampType,
forceTimestamp: forceTimestamp,
channelIdToUserTwitch: overrideChannelIdToUserTwitch ??
showHistoricalTimestamps:
chatStore.settings.showHistoricalTimestamps,
channelIdToUserTwitch:
overrideChannelIdToUserTwitch ??
chatStore.assetsStore.channelIdToUserTwitch,
currentChannelId:
overrideCurrentChannelId ?? chatStore.channelId,
@ -238,7 +241,10 @@ class ChatMessage extends StatelessWidget {
launchExternal: chatStore.settings.launchUrlExternal,
timestamp: chatStore.settings.timestampType,
forceTimestamp: forceTimestamp,
channelIdToUserTwitch: overrideChannelIdToUserTwitch ??
showHistoricalTimestamps:
chatStore.settings.showHistoricalTimestamps,
channelIdToUserTwitch:
overrideChannelIdToUserTwitch ??
chatStore.assetsStore.channelIdToUserTwitch,
currentChannelId:
overrideCurrentChannelId ?? chatStore.channelId,
@ -393,10 +399,12 @@ class ChatMessage extends StatelessWidget {
},
launchExternal: chatStore.settings.launchUrlExternal,
timestamp: chatStore.settings.timestampType,
forceTimestamp: forceTimestamp,
forceTimestamp: forceTimestamp,
showHistoricalTimestamps:
chatStore.settings.showHistoricalTimestamps,
channelIdToUserTwitch:
overrideChannelIdToUserTwitch ??
chatStore.assetsStore.channelIdToUserTwitch,
chatStore.assetsStore.channelIdToUserTwitch,
currentChannelId:
overrideCurrentChannelId ?? chatStore.channelId,
),
@ -523,10 +531,12 @@ class ChatMessage extends StatelessWidget {
badgeScale: chatStore.settings.badgeScale,
launchExternal: chatStore.settings.launchUrlExternal,
timestamp: chatStore.settings.timestampType,
forceTimestamp: forceTimestamp,
forceTimestamp: forceTimestamp,
showHistoricalTimestamps:
chatStore.settings.showHistoricalTimestamps,
channelIdToUserTwitch:
overrideChannelIdToUserTwitch ??
chatStore.assetsStore.channelIdToUserTwitch,
chatStore.assetsStore.channelIdToUserTwitch,
currentChannelId:
overrideCurrentChannelId ?? chatStore.channelId,
),

View file

@ -211,6 +211,16 @@ class ChatSettings extends StatelessWidget {
onChanged: (newValue) => settingsStore.timestampType =
TimestampType.values[timestampNames.indexOf(newValue)],
),
SettingsListSwitch(
title: 'Show timestamps on historical messages',
subtitle: const Text(
'Always show timestamps on messages loaded from chat history, '
'even when timestamps are disabled above.',
),
value: settingsStore.showHistoricalTimestamps,
onChanged: (newValue) =>
settingsStore.showHistoricalTimestamps = newValue,
),
const SectionHeader('Delay'),
SettingsListSwitch(
title: 'Auto-sync chat delay',

View file

@ -127,6 +127,7 @@ abstract class _SettingsStoreBase with Store {
static const defaultShowDeletedMessages = false;
static const defaultShowChatMessageDividers = false;
static const defaultTimestampType = TimestampType.disabled;
static const defaultShowHistoricalTimestamps = false;
// Alert defaults
static const defaultHighlightFirstTimeChatter = true;
@ -196,6 +197,10 @@ abstract class _SettingsStoreBase with Store {
@observable
var timestampType = defaultTimestampType;
@JsonKey(defaultValue: defaultShowHistoricalTimestamps)
@observable
var showHistoricalTimestamps = defaultShowHistoricalTimestamps;
@JsonKey(defaultValue: defaultHighlightFirstTimeChatter)
@observable
var highlightFirstTimeChatter = defaultHighlightFirstTimeChatter;
@ -314,6 +319,7 @@ abstract class _SettingsStoreBase with Store {
showDeletedMessages = defaultShowDeletedMessages;
showChatMessageDividers = defaultShowChatMessageDividers;
timestampType = defaultTimestampType;
showHistoricalTimestamps = defaultShowHistoricalTimestamps;
highlightFirstTimeChatter = defaultHighlightFirstTimeChatter;
showUserNotices = defaultShowUserNotices;

View file

@ -41,6 +41,8 @@ SettingsStore _$SettingsStoreFromJson(
unknownValue: TimestampType.disabled,
) ??
TimestampType.disabled
..showHistoricalTimestamps =
json['showHistoricalTimestamps'] as bool? ?? false
..highlightFirstTimeChatter =
json['highlightFirstTimeChatter'] as bool? ?? true
..showUserNotices = json['showUserNotices'] as bool? ?? true
@ -114,6 +116,7 @@ Map<String, dynamic> _$SettingsStoreToJson(
'showDeletedMessages': instance.showDeletedMessages,
'showChatMessageDividers': instance.showChatMessageDividers,
'timestampType': _$TimestampTypeEnumMap[instance.timestampType]!,
'showHistoricalTimestamps': instance.showHistoricalTimestamps,
'highlightFirstTimeChatter': instance.highlightFirstTimeChatter,
'showUserNotices': instance.showUserNotices,
'showTwitchEmotes': instance.showTwitchEmotes,
@ -547,6 +550,28 @@ mixin _$SettingsStore on _SettingsStoreBase, Store {
});
}
late final _$showHistoricalTimestampsAtom = Atom(
name: '_SettingsStoreBase.showHistoricalTimestamps',
context: context,
);
@override
bool get showHistoricalTimestamps {
_$showHistoricalTimestampsAtom.reportRead();
return super.showHistoricalTimestamps;
}
@override
set showHistoricalTimestamps(bool value) {
_$showHistoricalTimestampsAtom.reportWrite(
value,
super.showHistoricalTimestamps,
() {
super.showHistoricalTimestamps = value;
},
);
}
late final _$highlightFirstTimeChatterAtom = Atom(
name: '_SettingsStoreBase.highlightFirstTimeChatter',
context: context,
@ -1197,6 +1222,7 @@ fontSize: ${fontSize},
showDeletedMessages: ${showDeletedMessages},
showChatMessageDividers: ${showChatMessageDividers},
timestampType: ${timestampType},
showHistoricalTimestamps: ${showHistoricalTimestamps},
highlightFirstTimeChatter: ${highlightFirstTimeChatter},
showUserNotices: ${showUserNotices},
showTwitchEmotes: ${showTwitchEmotes},