Skip to content

Commit 6237118

Browse files
authored
feat: memories now has interesting/system type filter, better prompt... (#2412)
…for selection of these categories - also minor bug fixes
2 parents 75827d6 + 2ef25e8 commit 6237118

File tree

23 files changed

+2002
-188
lines changed

23 files changed

+2002
-188
lines changed

app/lib/backend/schema/memory.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum MemoryCategory { core, lifestyle, hobbies, interests, habits, work, skills, learnings, other }
1+
enum MemoryCategory { interesting, system }
22

33
enum MemoryVisibility { private, public }
44

@@ -40,7 +40,7 @@ class Memory {
4040
content: json['content'],
4141
category: MemoryCategory.values.firstWhere(
4242
(e) => e.toString().split('.').last == json['category'],
43-
orElse: () => MemoryCategory.other,
43+
orElse: () => MemoryCategory.interesting,
4444
),
4545
createdAt: DateTime.parse(json['created_at']).toLocal(),
4646
updatedAt: DateTime.parse(json['updated_at']).toLocal(),
@@ -50,9 +50,7 @@ class Memory {
5050
manuallyAdded: json['manually_added'] ?? false,
5151
edited: json['edited'] ?? false,
5252
deleted: json['deleted'] ?? false,
53-
visibility: json['visibility'] != null
54-
? (MemoryVisibility.values.asNameMap()[json['visibility']] ?? MemoryVisibility.public)
55-
: MemoryVisibility.public,
53+
visibility: json['visibility'] != null ? (MemoryVisibility.values.asNameMap()[json['visibility']] ?? MemoryVisibility.public) : MemoryVisibility.public,
5654
);
5755
}
5856

app/lib/pages/memories/page.dart

Lines changed: 222 additions & 17 deletions
Large diffs are not rendered by default.

app/lib/pages/memories/widgets/category_chip.dart

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,19 @@ class CategoryChip extends StatelessWidget {
2121

2222
Color _getCategoryColor() {
2323
switch (category) {
24-
case MemoryCategory.core:
24+
case MemoryCategory.interesting:
2525
return Colors.blue;
26-
case MemoryCategory.lifestyle:
27-
return Colors.purple;
28-
case MemoryCategory.interests:
29-
return Colors.green;
30-
case MemoryCategory.work:
31-
return Colors.orange;
32-
case MemoryCategory.skills:
33-
return Colors.red;
34-
case MemoryCategory.hobbies:
35-
return Colors.amber;
36-
case MemoryCategory.habits:
37-
return Colors.teal;
38-
case MemoryCategory.learnings:
39-
return Colors.indigo;
40-
case MemoryCategory.other:
26+
case MemoryCategory.system:
4127
return Colors.grey;
4228
}
4329
}
4430

4531
IconData _getCategoryIcon() {
4632
switch (category) {
47-
case MemoryCategory.core:
48-
return Icons.info_outline;
49-
case MemoryCategory.lifestyle:
50-
return Icons.home_outlined;
51-
case MemoryCategory.interests:
33+
case MemoryCategory.interesting:
5234
return Icons.star_outline;
53-
case MemoryCategory.work:
54-
return Icons.work_outline;
55-
case MemoryCategory.skills:
56-
return Icons.psychology_outlined;
57-
case MemoryCategory.hobbies:
58-
return Icons.sports_esports_outlined;
59-
case MemoryCategory.habits:
60-
return Icons.repeat_outlined;
61-
case MemoryCategory.learnings:
62-
return Icons.school_outlined;
63-
case MemoryCategory.other:
64-
return Icons.label_outline;
35+
case MemoryCategory.system:
36+
return Icons.settings_outlined;
6537
}
6638
}
6739

@@ -71,32 +43,11 @@ class CategoryChip extends StatelessWidget {
7143
// Use shorter display names for categories
7244
String displayName;
7345
switch (category) {
74-
case MemoryCategory.core:
75-
displayName = "Core";
46+
case MemoryCategory.interesting:
47+
displayName = "Interesting";
7648
break;
77-
case MemoryCategory.lifestyle:
78-
displayName = "Life";
79-
break;
80-
case MemoryCategory.interests:
81-
displayName = "Interest";
82-
break;
83-
case MemoryCategory.work:
84-
displayName = "Work";
85-
break;
86-
case MemoryCategory.skills:
87-
displayName = "Skills";
88-
break;
89-
case MemoryCategory.hobbies:
90-
displayName = "Hobby";
91-
break;
92-
case MemoryCategory.habits:
93-
displayName = "Habit";
94-
break;
95-
case MemoryCategory.learnings:
96-
displayName = "Learn";
97-
break;
98-
case MemoryCategory.other:
99-
displayName = "Other";
49+
case MemoryCategory.system:
50+
displayName = "System";
10051
break;
10152
}
10253

app/lib/pages/memories/widgets/memory_dialog.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ class _MemoryDialogState extends State<MemoryDialog> {
222222
}
223223
MixpanelManager().memoriesPageEditedMemory();
224224
} else {
225-
widget.provider.createMemory(value, selectedVisibility);
226-
MixpanelManager().memoriesPageCreatedMemory(MemoryCategory.values.first);
225+
widget.provider.createMemory(value, selectedVisibility, MemoryCategory.interesting);
226+
MixpanelManager().memoriesPageCreatedMemory(MemoryCategory.interesting);
227227
}
228228
Navigator.pop(context);
229229
}

app/lib/providers/memories_provider.dart

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class MemoriesProvider extends ChangeNotifier {
1515
bool _loading = true;
1616
String _searchQuery = '';
1717
MemoryCategory? _categoryFilter;
18+
bool _excludeInteresting = false;
1819
List<Tuple2<MemoryCategory, int>> categories = [];
1920
MemoryCategory? selectedCategory;
2021

@@ -23,21 +24,36 @@ class MemoriesProvider extends ChangeNotifier {
2324
bool get loading => _loading;
2425
String get searchQuery => _searchQuery;
2526
MemoryCategory? get categoryFilter => _categoryFilter;
27+
bool get excludeInteresting => _excludeInteresting;
2628

2729
List<Memory> get filteredMemories {
2830
return _memories.where((memory) {
2931
// Apply search filter
30-
final matchesSearch =
31-
_searchQuery.isEmpty || memory.content.decodeString.toLowerCase().contains(_searchQuery.toLowerCase());
32-
33-
// Apply category filter
34-
final matchesCategory = _categoryFilter == null || memory.category == _categoryFilter;
32+
final matchesSearch = _searchQuery.isEmpty || memory.content.decodeString.toLowerCase().contains(_searchQuery.toLowerCase());
33+
34+
// Apply category filter or exclusion logic
35+
bool categoryMatch;
36+
if (_excludeInteresting) {
37+
// Show all categories except interesting
38+
categoryMatch = memory.category != MemoryCategory.interesting;
39+
} else if (_categoryFilter != null) {
40+
// Show only selected category
41+
categoryMatch = memory.category == _categoryFilter;
42+
} else {
43+
// Show all categories if no filter is applied
44+
categoryMatch = true;
45+
}
3546

36-
return matchesSearch && matchesCategory;
47+
return matchesSearch && categoryMatch;
3748
}).toList()
3849
..sort((a, b) => b.createdAt.compareTo(a.createdAt));
3950
}
4051

52+
void setExcludeInteresting(bool exclude) {
53+
_excludeInteresting = exclude;
54+
notifyListeners();
55+
}
56+
4157
void setCategory(MemoryCategory? category) {
4258
selectedCategory = category;
4359
notifyListeners();
@@ -50,6 +66,7 @@ class MemoriesProvider extends ChangeNotifier {
5066

5167
void setCategoryFilter(MemoryCategory? category) {
5268
_categoryFilter = category;
69+
_excludeInteresting = false; // Reset exclude filter when setting a category filter
5370
notifyListeners();
5471
}
5572

@@ -70,10 +87,7 @@ class MemoriesProvider extends ChangeNotifier {
7087
notifyListeners();
7188

7289
_memories = await getMemories();
73-
_unreviewed = _memories
74-
.where(
75-
(memory) => !memory.reviewed && memory.createdAt.isAfter(DateTime.now().subtract(const Duration(days: 1))))
76-
.toList();
90+
_unreviewed = _memories.where((memory) => !memory.reviewed && memory.createdAt.isAfter(DateTime.now().subtract(const Duration(days: 1)))).toList();
7791

7892
_loading = false;
7993
_setCategories();
@@ -97,8 +111,7 @@ class MemoriesProvider extends ChangeNotifier {
97111
_setCategories();
98112
}
99113

100-
void createMemory(String content,
101-
[MemoryVisibility visibility = MemoryVisibility.public, MemoryCategory category = MemoryCategory.core]) async {
114+
void createMemory(String content, [MemoryVisibility visibility = MemoryVisibility.public, MemoryCategory category = MemoryCategory.interesting]) async {
102115
final newMemory = Memory(
103116
id: const Uuid().v4(),
104117
uid: SharedPreferencesUtil().uid,

app/lib/utils/analytics/mixpanel.dart

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ class MixpanelManager {
6767
setUserProperty('\$email', SharedPreferencesUtil().email);
6868
}
6969

70-
void track(String eventName, {Map<String, dynamic>? properties}) =>
71-
_mixpanel?.track(eventName, properties: properties);
70+
void track(String eventName, {Map<String, dynamic>? properties}) => _mixpanel?.track(eventName, properties: properties);
7271

7372
void startTimingEvent(String eventName) => _mixpanel?.timeEvent(eventName);
7473

@@ -148,8 +147,7 @@ class MixpanelManager {
148147

149148
void deviceDisconnected() => track('Device Disconnected');
150149

151-
void memoriesPageCategoryOpened(MemoryCategory category) =>
152-
track('Fact Page Category Opened', properties: {'category': category.toString().split('.').last});
150+
void memoriesPageCategoryOpened(MemoryCategory category) => track('Fact Page Category Opened', properties: {'category': category.toString().split('.').last});
153151

154152
void memoriesPageDeletedMemory(Memory memory) => track(
155153
'Fact Page Deleted Fact',
@@ -164,8 +162,7 @@ class MixpanelManager {
164162

165163
void memoriesPageReviewBtn() => track('Fact page Review Button Pressed');
166164

167-
void memoriesPageCreatedMemory(MemoryCategory category) =>
168-
track('Fact Page Created Fact', properties: {'fact_category': category.toString().split('.').last});
165+
void memoriesPageCreatedMemory(MemoryCategory category) => track('Fact Page Created Fact', properties: {'fact_category': category.toString().split('.').last});
169166

170167
void memorySearched(String query, int resultsCount) {
171168
track('Fact Searched', properties: {
@@ -215,6 +212,8 @@ class MixpanelManager {
215212
});
216213
}
217214

215+
void memoriesFiltered(String filter) => track('Facts Filtered', properties: {'filter': filter});
216+
218217
void memoriesManagementSheetOpened() => track('Facts Management Sheet Opened');
219218

220219
Map<String, dynamic> _getTranscriptProperties(String transcript) {
@@ -249,14 +248,11 @@ class MixpanelManager {
249248
track('Memory Created', properties: properties);
250249
}
251250

252-
void conversationListItemClicked(ServerConversation conversation, int idx) =>
253-
track('Memory List Item Clicked', properties: getConversationEventProperties(conversation));
251+
void conversationListItemClicked(ServerConversation conversation, int idx) => track('Memory List Item Clicked', properties: getConversationEventProperties(conversation));
254252

255-
void conversationShareButtonClick(ServerConversation conversation) =>
256-
track('Memory Share Button Clicked', properties: getConversationEventProperties(conversation));
253+
void conversationShareButtonClick(ServerConversation conversation) => track('Memory Share Button Clicked', properties: getConversationEventProperties(conversation));
257254

258-
void conversationDeleted(ServerConversation conversation) =>
259-
track('Memory Deleted', properties: getConversationEventProperties(conversation));
255+
void conversationDeleted(ServerConversation conversation) => track('Memory Deleted', properties: getConversationEventProperties(conversation));
260256

261257
void chatMessageSent({
262258
required String message,
@@ -285,25 +281,21 @@ class MixpanelManager {
285281

286282
void speechProfileCapturePageClicked() => track('Speech Profile Capture Page Clicked');
287283

288-
void showDiscardedMemoriesToggled(bool showDiscarded) =>
289-
track('Show Discarded Memories Toggled', properties: {'show_discarded': showDiscarded});
284+
void showDiscardedMemoriesToggled(bool showDiscarded) => track('Show Discarded Memories Toggled', properties: {'show_discarded': showDiscarded});
290285

291-
void chatMessageConversationClicked(ServerConversation conversation) =>
292-
track('Chat Message Memory Clicked', properties: getConversationEventProperties(conversation));
286+
void chatMessageConversationClicked(ServerConversation conversation) => track('Chat Message Memory Clicked', properties: getConversationEventProperties(conversation));
293287

294288
void addManualConversationClicked() => track('Add Manual Memory Clicked');
295289

296-
void manualConversationCreated(ServerConversation conversation) =>
297-
track('Manual Memory Created', properties: getConversationEventProperties(conversation));
290+
void manualConversationCreated(ServerConversation conversation) => track('Manual Memory Created', properties: getConversationEventProperties(conversation));
298291

299292
void setUserProperties(String whatDoYouDo, String whereDoYouPlanToUseYourFriend, String ageRange) {
300293
setUserProperty('What the user does', whatDoYouDo);
301294
setUserProperty('Using Omi At', whereDoYouPlanToUseYourFriend);
302295
setUserProperty('Age Range', ageRange);
303296
}
304297

305-
void reProcessConversation(ServerConversation conversation) =>
306-
track('Re-process Memory', properties: getConversationEventProperties(conversation));
298+
void reProcessConversation(ServerConversation conversation) => track('Re-process Memory', properties: getConversationEventProperties(conversation));
307299

308300
void developerModeEnabled() {
309301
track('Developer Mode Enabled');
@@ -325,17 +317,13 @@ class MixpanelManager {
325317

326318
void supportContacted() => track('Support Contacted');
327319

328-
void copiedConversationDetails(ServerConversation conversation, {String source = ''}) =>
329-
track('Copied Memory Detail $source'.trim(), properties: getConversationEventProperties(conversation));
320+
void copiedConversationDetails(ServerConversation conversation, {String source = ''}) => track('Copied Memory Detail $source'.trim(), properties: getConversationEventProperties(conversation));
330321

331-
void checkedActionItem(ServerConversation conversation, int idx) =>
332-
track('Checked Action Item', properties: getConversationEventProperties(conversation));
322+
void checkedActionItem(ServerConversation conversation, int idx) => track('Checked Action Item', properties: getConversationEventProperties(conversation));
333323

334-
void uncheckedActionItem(ServerConversation conversation, int idx) =>
335-
track('Unchecked Action Item', properties: getConversationEventProperties(conversation));
324+
void uncheckedActionItem(ServerConversation conversation, int idx) => track('Unchecked Action Item', properties: getConversationEventProperties(conversation));
336325

337-
void deletedActionItem(ServerConversation conversation) =>
338-
track('Deleted Action Item', properties: getConversationEventProperties(conversation));
326+
void deletedActionItem(ServerConversation conversation) => track('Deleted Action Item', properties: getConversationEventProperties(conversation));
339327

340328
void upgradeModalDismissed() => track('Upgrade Modal Dismissed');
341329

0 commit comments

Comments
 (0)