fix: web providers

This commit is contained in:
2024-08-31 01:02:08 +03:00
parent 1e3d5a5728
commit 8755d639ca
5 changed files with 16 additions and 6 deletions

View File

@@ -155,9 +155,10 @@ class AuthProvider extends ChangeNotifier
debugPrint('fb user changed: $user');
_fbUser = user;
final context = appGlobalKey.currentContext!;
final userProvider = Provider.of<UserProvider>(context, listen: false);
final userProvider = UserProvider.instance;
if (user != null) {
final context = appGlobalKey.currentContext!;
final loadingProvider = Provider.of<LoadingProvider>(
context,
listen: false,

View File

@@ -25,6 +25,7 @@ import '../../../core/utils/secrets_base.dart';
class UserProvider extends ChangeNotifier with RepositoryProviderMixin {
var _current = User.guest();
static final UserProvider instance = UserProvider();
User get current => _current;
StreamSubscription? _userDataSub;
@@ -249,4 +250,4 @@ mixin UserProviderMixin {
UserProvider get userProvider =>
UserProvider.of(appGlobalKey.currentContext!);
User get user => userProvider.current;
}
}

View File

@@ -35,8 +35,8 @@ class PlatformHelper {
static final isMacOS = !kIsWeb && Platform.isMacOS;
static final isWindows = !kIsWeb && Platform.isWindows;
static final isLinux = !kIsWeb && Platform.isLinux;
static final isDesktop = Platform.isMacOS || Platform.isWindows || Platform.isLinux;
static final isMobile = !isDesktop;
static final isDesktop = !isMobile && (Platform.isMacOS || Platform.isWindows || Platform.isLinux);
static const isMobile = kIsWeb;
static final canUseAppleSignIn = isApple;
static final canUseGoogleSignIn = isAndroid;

View File

@@ -45,7 +45,7 @@ void main() async {
final _loadingProvider = LoadingProvider();
final _authProvider = AuthProvider();
final _characterProvider = CharacterProvider();
final _userProvider = UserProvider();
final _userProvider = UserProvider.instance;
final _repositoryProvider = RepositoryProvider();
final _libraryProvider = LibraryProvider();
final _intlService = IntlService.instance;

View File

@@ -154,5 +154,13 @@
window.location.href = '/'
}
</script>
<script>
// prettier-ignore
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys getNextSurveyStep onSessionId".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('phc_1ZhjwOjdk5HRTb0w5YZJXqKvm7o4kDAGlAp9VJXwz0K', {
api_host: 'https://us.i.posthog.com',
person_profiles: 'identified_only',
})
</script>
</body>
</html>