2022-11-17 16:04:14 +00:00
|
|
|
enum TimelineType {
|
|
|
|
home,
|
|
|
|
global,
|
|
|
|
local,
|
2023-11-15 21:05:45 +00:00
|
|
|
circle,
|
2022-11-17 16:04:14 +00:00
|
|
|
profile,
|
2022-12-08 18:37:30 +00:00
|
|
|
self;
|
|
|
|
|
|
|
|
String toLabel() {
|
|
|
|
switch (this) {
|
|
|
|
case TimelineType.home:
|
2023-01-30 05:25:06 +00:00
|
|
|
return 'My Network';
|
2022-12-08 18:37:30 +00:00
|
|
|
case TimelineType.global:
|
2023-01-30 05:25:06 +00:00
|
|
|
return 'Global Fediverse';
|
2022-12-08 18:37:30 +00:00
|
|
|
case TimelineType.local:
|
2023-01-30 05:25:06 +00:00
|
|
|
return 'Local Fediverse';
|
2023-11-15 21:05:45 +00:00
|
|
|
case TimelineType.circle:
|
|
|
|
return 'Circles';
|
2022-12-08 18:37:30 +00:00
|
|
|
case TimelineType.profile:
|
|
|
|
return 'Profile';
|
|
|
|
case TimelineType.self:
|
2023-01-30 05:25:06 +00:00
|
|
|
return 'My Posts';
|
2022-12-08 18:37:30 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-17 16:04:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class TimelineIdentifiers {
|
|
|
|
final TimelineType timeline;
|
|
|
|
final String auxData;
|
2023-11-16 21:21:06 +00:00
|
|
|
final String label;
|
2022-11-22 05:21:41 +00:00
|
|
|
|
2023-11-16 21:21:06 +00:00
|
|
|
const TimelineIdentifiers({
|
|
|
|
required this.timeline,
|
|
|
|
this.auxData = '',
|
|
|
|
this.label = '',
|
|
|
|
});
|
2022-11-17 16:04:14 +00:00
|
|
|
|
|
|
|
String toHumanKey() {
|
|
|
|
return auxData.isEmpty ? timeline.name : '${timeline.name}_$auxData';
|
|
|
|
}
|
|
|
|
|
2023-11-16 21:21:06 +00:00
|
|
|
String toLabel() {
|
|
|
|
if (label.isNotEmpty) {
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (timeline != TimelineType.circle) {
|
|
|
|
return timeline.toLabel();
|
|
|
|
}
|
|
|
|
|
|
|
|
return '${timeline.toLabel()} $auxData';
|
|
|
|
}
|
|
|
|
|
2022-11-17 16:04:14 +00:00
|
|
|
factory TimelineIdentifiers.home() =>
|
2023-11-16 21:21:06 +00:00
|
|
|
const TimelineIdentifiers(timeline: TimelineType.home);
|
2022-11-17 16:04:14 +00:00
|
|
|
|
2024-07-24 15:39:23 +00:00
|
|
|
factory TimelineIdentifiers.myPosts() =>
|
|
|
|
const TimelineIdentifiers(timeline: TimelineType.self);
|
|
|
|
|
2022-12-17 17:17:47 +00:00
|
|
|
factory TimelineIdentifiers.profile(String profileId) => TimelineIdentifiers(
|
2022-11-29 15:33:16 +00:00
|
|
|
timeline: TimelineType.profile,
|
|
|
|
auxData: profileId,
|
|
|
|
);
|
|
|
|
|
2022-11-17 16:04:14 +00:00
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return auxData.isEmpty
|
|
|
|
? 'TimelineIdentifiers{timeline: $timeline)'
|
|
|
|
: 'TimelineIdentifiers{timeline: $timeline, auxData: $auxData}';
|
|
|
|
}
|
2022-11-29 15:33:16 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
bool operator ==(Object other) =>
|
|
|
|
identical(this, other) ||
|
2022-12-17 17:17:47 +00:00
|
|
|
other is TimelineIdentifiers &&
|
|
|
|
runtimeType == other.runtimeType &&
|
|
|
|
timeline == other.timeline &&
|
2024-12-01 19:57:47 +00:00
|
|
|
auxData == other.auxData &&
|
|
|
|
label == other.label;
|
2022-11-29 15:33:16 +00:00
|
|
|
|
|
|
|
@override
|
2024-12-01 19:57:47 +00:00
|
|
|
int get hashCode => timeline.hashCode ^ auxData.hashCode ^ label.hashCode;
|
2022-11-17 16:04:14 +00:00
|
|
|
}
|