Skip to content

Commit

Permalink
Use decodeString for plugin details and prompts (#1184)
Browse files Browse the repository at this point in the history
  • Loading branch information
beastoin authored Oct 26, 2024
2 parents 7aaeedc + 202d433 commit 6fabd6d
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 19 deletions.
6 changes: 3 additions & 3 deletions app/lib/pages/apps/app_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class _AppDetailPageState extends State<AppDetailPage> {
children: [
SizedBox(height: widget.app.ratingAvg != null ? 4 : 0),
Text(
widget.app.description,
widget.app.description.decodeString,
style: const TextStyle(color: Colors.grey, fontSize: 14),
),
],
Expand Down Expand Up @@ -209,7 +209,7 @@ class _AppDetailPageState extends State<AppDetailPage> {
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
(widget.app.memoryPrompt ?? '').decodeSting,
(widget.app.memoryPrompt ?? '').decodeString,
style: const TextStyle(color: Colors.grey, fontSize: 15, height: 1.4),
),
)
Expand All @@ -228,7 +228,7 @@ class _AppDetailPageState extends State<AppDetailPage> {
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
widget.app.chatPrompt ?? '',
(widget.app.chatPrompt ?? '').decodeString,
style: const TextStyle(color: Colors.grey, fontSize: 15, height: 1.4),
),
)
Expand Down
3 changes: 2 additions & 1 deletion app/lib/pages/apps/list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:friend_private/providers/app_provider.dart';
import 'package:friend_private/utils/analytics/mixpanel.dart';
import 'package:friend_private/utils/other/temp.dart';
import 'package:friend_private/widgets/dialog.dart';
import 'package:friend_private/widgets/extensions/string.dart';
import 'package:provider/provider.dart';

import 'app_detail.dart';
Expand Down Expand Up @@ -65,7 +66,7 @@ class AppListItem extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
app.description,
app.description.decodeString,
maxLines: 2,
style: const TextStyle(color: Colors.grey, fontSize: 14),
),
Expand Down
8 changes: 4 additions & 4 deletions app/lib/pages/chat/widgets/ai_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ Widget buildMessageWidget(ServerMessage message, Function(String) sendMessage, b
return MemoriesMessageWidget(
showTypingIndicator: showTypingIndicator,
messageMemories: message.memories.length > 3 ? message.memories.sublist(0, 3) : message.memories,
messageText: message.isEmpty ? '...' : message.text.decodeSting,
messageText: message.isEmpty ? '...' : message.text.decodeString,
updateMemory: updateMemory,
);
} else if (message.type == MessageType.daySummary) {
return DaySummaryWidget(
showTypingIndicator: showTypingIndicator, messageText: message.text.decodeSting, date: message.createdAt);
showTypingIndicator: showTypingIndicator, messageText: message.text.decodeString, date: message.createdAt);
} else if (displayOptions) {
return InitialMessageWidget(
showTypingIndicator: showTypingIndicator, messageText: message.text.decodeSting, sendMessage: sendMessage);
showTypingIndicator: showTypingIndicator, messageText: message.text.decodeString, sendMessage: sendMessage);
} else {
return NormalMessageWidget(showTypingIndicator: showTypingIndicator, messageText: message.text.decodeSting);
return NormalMessageWidget(showTypingIndicator: showTypingIndicator, messageText: message.text.decodeString);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/lib/pages/chat/widgets/user_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class HumanMessage extends StatelessWidget {
),
padding: const EdgeInsets.all(16.0),
child: Text(
message.text.decodeSting,
message.text.decodeString,
style: Theme.of(context).textTheme.bodyMedium,
),
),
Expand Down
4 changes: 2 additions & 2 deletions app/lib/pages/facts/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class _FactsPageState extends State<_FactsPage> {
return;
}

final contentController = TextEditingController(text: fact?.content.decodeSting ?? '');
final contentController = TextEditingController(text: fact?.content.decodeString ?? '');
final formKey = GlobalKey<FormState>();

await showDialog(
Expand Down Expand Up @@ -402,7 +402,7 @@ class _FactsPageState extends State<_FactsPage> {
child: Padding(
padding: const EdgeInsets.only(top: 16.0),
child: ListTile(
title: Text(fact.content.decodeSting),
title: Text(fact.content.decodeString),
onTap: () => _showFactDialog(context, provider, fact: fact),
),
),
Expand Down
4 changes: 2 additions & 2 deletions app/lib/pages/memories/widgets/memory_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ class _MemoryListItemState extends State<MemoryListItem> {
widget.memory.discarded
? const SizedBox.shrink()
: Text(
structured.title.decodeSting,
structured.title.decodeString,
style: Theme.of(context).textTheme.titleLarge,
maxLines: 1,
),
widget.memory.discarded ? const SizedBox.shrink() : const SizedBox(height: 8),
widget.memory.discarded
? const SizedBox.shrink()
: Text(
structured.overview.decodeSting,
structured.overview.decodeString,
style: Theme.of(context)
.textTheme
.bodyMedium!
Expand Down
2 changes: 1 addition & 1 deletion app/lib/pages/memory_detail/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class TranscriptWidgets extends StatelessWidget {
SizedBox(height: provider.memory.transcriptSegments.isEmpty ? 16 : 0),
provider.memory.transcriptSegments.isEmpty
? ExpandableTextWidget(
text: (provider.memory.externalIntegration?.text ?? '').decodeSting,
text: (provider.memory.externalIntegration?.text ?? '').decodeString,
maxLines: 10000,
linkColor: Colors.grey.shade300,
style: TextStyle(color: Colors.grey.shade300, fontSize: 15, height: 1.3),
Expand Down
8 changes: 4 additions & 4 deletions app/lib/pages/memory_detail/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class GetSummaryWidgets extends StatelessWidget {
children: [
const SizedBox(height: 24),
Text(
memory.discarded ? 'Discarded Memory' : memory.structured.title.decodeSting,
memory.discarded ? 'Discarded Memory' : memory.structured.title.decodeString,
style: Theme.of(context).textTheme.titleLarge!.copyWith(fontSize: 32),
),
const SizedBox(height: 16),
Expand Down Expand Up @@ -123,7 +123,7 @@ class ActionItemsListWidget extends StatelessWidget {
onPressed: () {
Clipboard.setData(ClipboardData(
text:
'- ${provider.memory.structured.actionItems.map((e) => e.description.decodeSting).join('\n- ')}',
'- ${provider.memory.structured.actionItems.map((e) => e.description.decodeString).join('\n- ')}',
));
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Action items copied to clipboard'),
Expand Down Expand Up @@ -208,7 +208,7 @@ class ActionItemsListWidget extends StatelessWidget {
Expanded(
child: SelectionArea(
child: Text(
item.description.decodeSting,
item.description.decodeString,
style: TextStyle(color: Colors.grey.shade300, fontSize: 16, height: 1.3),
),
),
Expand Down Expand Up @@ -544,7 +544,7 @@ class GetAppsWidgets extends StatelessWidget {
)
: const SizedBox.shrink(),
ExpandableTextWidget(
text: appResponse.content.decodeSting.trim(),
text: appResponse.content.decodeString.trim(),
isExpanded: provider.appResponseExpanded[i],
toggleExpand: () {
debugPrint('appResponseExpanded: ${provider.appResponseExpanded}');
Expand Down
2 changes: 1 addition & 1 deletion app/lib/widgets/extensions/string.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:convert';

extension StringExtensions on String {
String get decodeSting {
String get decodeString {
try {
return utf8.decode(codeUnits);
} on Exception catch (_) {
Expand Down

0 comments on commit 6fabd6d

Please sign in to comment.