Skip to content

Commit

Permalink
Persona mobile fixes again (#1831)
Browse files Browse the repository at this point in the history
  • Loading branch information
beastoin authored Feb 19, 2025
2 parents 5f83f92 + e04bf9f commit fe2412d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 15 deletions.
2 changes: 2 additions & 0 deletions app/lib/backend/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ Future<void> updateGivenName(String fullName) async {
Future<void> signInAnonymously() async {
try {
await FirebaseAuth.instance.signInAnonymously();
var user = FirebaseAuth.instance.currentUser!;
SharedPreferencesUtil().uid = user.uid;
} catch (e) {
Logger.handle(e, null, message: 'An error occurred while signing in. Please try again later.');
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/pages/apps/app_detail/app_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class _AppDetailPageState extends State<AppDetailPage> {
);
} else {
Share.share(
'Check out this Persona on Omi AI: ${app.name} by ${app.author} \n\n${app.description.decodeString}\n\n\nhttps://persona.omi.me/u/${app.username}',
'Check out this Persona on Omi AI: ${app.name} by ${app.author} \n\n${app.description.decodeString}\n\n\nhttps://personas.omi.me/u/${app.username}',
subject: app.name,
);
}
Expand Down
26 changes: 14 additions & 12 deletions app/lib/pages/persona/persona_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:friend_private/utils/other/temp.dart';
import 'package:friend_private/widgets/sign_in_button.dart';
import 'package:provider/provider.dart';
import 'package:share_plus/share_plus.dart';
import 'package:url_launcher/url_launcher.dart';

class PersonaProfilePage extends StatefulWidget {
const PersonaProfilePage({
Expand Down Expand Up @@ -123,7 +124,8 @@ class _PersonaProfilePageState extends State<PersonaProfilePage> {
),
const SizedBox(height: 16),
TextButton(
onPressed: () {
onPressed: () async {
await launchUrl(Uri.parse('https://www.omi.me/?_ref=omi_persona_flow'));
// Navigator.pop(context);
// var persona = context.read<PersonaProvider>().userPersona;
// routeToPage(context, UpdatePersonaPage(app: persona));
Expand Down Expand Up @@ -171,14 +173,14 @@ class _PersonaProfilePageState extends State<PersonaProfilePage> {
backgroundColor: Colors.transparent,
appBar: AppBar(
backgroundColor: Colors.transparent,
actions: [
IconButton(
icon: const Icon(Icons.settings, color: Colors.white),
onPressed: () {
// TODO: Implement settings
},
),
],
// actions: [
// IconButton(
// icon: const Icon(Icons.settings, color: Colors.white),
// onPressed: () {
// // TODO: Implement settings
// },
// ),
// ],
),
body: provider.isLoading || provider.userPersona == null
? const Center(
Expand Down Expand Up @@ -246,7 +248,7 @@ class _PersonaProfilePageState extends State<PersonaProfilePage> {
),
const SizedBox(height: 8),
Text(
"40% Clone",
"40% Cloned",
style: TextStyle(
color: Colors.grey[600],
fontSize: 16,
Expand All @@ -258,7 +260,7 @@ class _PersonaProfilePageState extends State<PersonaProfilePage> {
child: TextButton(
onPressed: () {
Share.share(
'Check out this Persona on Omi AI: ${provider.userPersona!.name} by me \n\nhttps://persona.omi.me/u/${provider.userPersona!.name}',
'Check out this Persona on Omi AI: ${provider.userPersona!.name} by me \n\nhttps://personas.omi.me/u/${provider.userPersona!.username}',
subject: '${provider.userPersona!.name} Persona',
);
},
Expand Down Expand Up @@ -351,7 +353,7 @@ class _PersonaProfilePageState extends State<PersonaProfilePage> {
),
_buildSocialLink(
icon: 'assets/images/x_logo_mini.png',
text: 'mohsinxyz_',
text: provider.userPersona!.username ?? 'username',
isConnected: true,
),
const SizedBox(height: 12),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/pages/persona/twitter/verify_identity_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _VerifyIdentityScreenState extends State<VerifyIdentityScreen> {
if (handle.isEmpty) {
handle = provider.twitterProfile['profile'];
}
final tweetText = Uri.encodeComponent('Verifying my clone: https://persona.omi.me/u/$handle');
final tweetText = Uri.encodeComponent('Verifying my clone: https://personas.omi.me/u/$handle');
final twitterUrl = 'https://twitter.com/intent/tweet?text=$tweetText';

if (await canLaunchUrl(Uri.parse(twitterUrl))) {
Expand Down
4 changes: 3 additions & 1 deletion app/lib/pages/persona/update_persona.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class _UpdatePersonaPageState extends State<UpdatePersonaPage> {
if (didPop) {
context.read<PersonaProvider>().resetForm();
if (widget.fromNewFlow) {
routeToPage(context, DeciderWidget(), replace: true);
Future.delayed(Duration.zero, () {
routeToPage(context, DeciderWidget(), replace: true);
});
} else {
Future.delayed(Duration.zero, () {
Navigator.pop(context);
Expand Down
1 change: 1 addition & 0 deletions app/lib/pages/settings/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class _SettingsPageState extends State<SettingsPage> {
return getDialog(context, () {
Navigator.of(context).pop();
}, () {
SharedPreferencesUtil().hasOmiDevice = null;
signOut();
Navigator.of(context).pop();
routeToPage(context, const DeciderWidget(), replace: true);
Expand Down
10 changes: 10 additions & 0 deletions app/lib/providers/auth_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ class AuthenticationProvider extends BaseProvider {
await FirebaseAuth.instance.currentUser?.linkWithCredential(credential);
} catch (e) {
print('Error linking with Google: $e');
if (e is FirebaseAuthException && e.code == 'credential-already-in-use') {
AppSnackbar.showSnackbarError('An account with this email already exists on our platform.');
} else {
AppSnackbar.showSnackbarError('Failed to link with Apple, please try again.');
}
rethrow;
} finally {
setLoading(false);
Expand All @@ -162,6 +167,11 @@ class AuthenticationProvider extends BaseProvider {
await FirebaseAuth.instance.currentUser?.linkWithProvider(appleProvider);
} catch (e) {
print('Error linking with Apple: $e');
if (e is FirebaseAuthException && e.code == 'credential-already-in-use') {
AppSnackbar.showSnackbarError('An account with this email already exists on our platform.');
} else {
AppSnackbar.showSnackbarError('Failed to link with Apple, please try again.');
}
rethrow;
} finally {
setLoading(false);
Expand Down

0 comments on commit fe2412d

Please sign in to comment.