Git Product home page Git Product logo

Comments (22)

HayesGordon avatar HayesGordon commented on June 19, 2024

Hi, @rlee1990. We will release a new version soon to make this a bit more clear.

Before calling .currentUser you now need to set a user first, using streamClient.setUser(User('id', data: data), 'user-token');

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

@HayesGordon I did that and I still get a null user:

streamClient.setUser(
        feed.User(id: u, data: {
          'name': currentUser.data!.value.name,
          'image': currentUser.data!.value.currentProfileImage
        }),
        feed.Token(currentUser.data!.value.currentToken!));

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

@sachaarbonel Any idea at to what the issue could be?

from stream-feed-flutter.

sachaarbonel avatar sachaarbonel commented on June 19, 2024

Hey sorry for the late response. As @HayesGordon said we did a change in this release (0.4.0) to be able to swap a User token at runtime (think of using a different profile for example) without instantiating StreamFeedClient again.
I think the reason why you have an error is that you try to setUser with data from currentUser (currentUser.data etc), but currentUser is not "set" yet. Maybe try to hardcode the value of name, image and token and see if it works

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

@sachaarbonel sorry for the confusion the currentUser in the code above is from Firebase which I get from a riverpod provider. I have confirmed that that information is coming in and that the setUser function is running.

from stream-feed-flutter.

sachaarbonel avatar sachaarbonel commented on June 19, 2024

oh, I see. Are you awaiting setUser? It's a future now, so might be it

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

@sachaarbonel Yes I am.
I set the setUser up in a FutureProvider for Riverpod.
The watch it here:

return watch(streamUser).when(
              data: (sUser) {
                final streamClient = context.read(client);
                switch (data.currentAccount) {
                  case 'personal':
                    return ScreenTypeLayout(
                      mobile: TabView(
                        currentUser: data,
                        streamClient: streamClient!,
                      ),
                    );
                  default:
                    return ScreenTypeLayout(
                      mobile: TabView(
                        currentUser: data,
                        streamClient: streamClient!,
                      ),
                    );
                }
              },

from stream-feed-flutter.

sachaarbonel avatar sachaarbonel commented on June 19, 2024

So sUser is null inside your data callback?

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

@sachaarbonel nope this is what it returns:
I/flutter (25177): SUser data: StreamUser(ytmORLAvAiWvYGt2jyL2GzeENMc2_personal, 2021-08-19 16:59:15.430621Z)

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

It looks like the data might be coming back as null. I can call

final u = widget.streamClient
        .user('${widget.user.uid}_${widget.user.currentAccount}');

With me putting in the username and trying to print u.data it returns null.

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

Any update on this?

from stream-feed-flutter.

sachaarbonel avatar sachaarbonel commented on June 19, 2024

Hey, @rlee1990 sorry I thought you meant User was null. The underlying data is. A workaround is to call profile just after you setUser

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

@sachaarbonel when you say call profile is this a get stream function?

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

Nevermind

from stream-feed-flutter.

sachaarbonel avatar sachaarbonel commented on June 19, 2024

yes it's a method from StreamUser
await currentUser.profile()

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

I am still having an issue. @sachaarbonel is there an example anywhere so I can try to compare?

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

I tried a few more times and still get the same issue I don't think the current user is being set.
@sachaarbonel

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

Any update @HayesGordon or @sachaarbonel I can't seem to find a solution.

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

Hi @sachaarbonel any other recommendations?

from stream-feed-flutter.

xsahil03x avatar xsahil03x commented on June 19, 2024

It looks like the data might be coming back as null. I can call

final u = widget.streamClient
        .user('${widget.user.uid}_${widget.user.currentAccount}');

With me putting in the username and trying to print u.data it returns null.

@rlee1990 , After setting the user successfully, you should use
client.currentUser to get the connected user.

client.user is used to create a new user instance. that's why user.data returns null.

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

Hi @xsahil03x Im still having the same issue

from stream-feed-flutter.

rlee1990 avatar rlee1990 commented on June 19, 2024

This is my riverpod provider:

final streamUser = FutureProvider.autoDispose((ref) async {
  final streamClient = ref.read(client);
  final currentUser = ref.watch(userAccount);
  if (streamClient != null && currentUser.asData!.value.uid != null) {
    print('Feed User set.');
    var u =
        '${currentUser.asData!.value.uid}_${currentUser.asData!.value.currentAccount}';
    final user = await streamClient.setUser(
        feed.User(
          id: u,
        ),
        feed.Token(currentUser.asData!.value.currentToken!));
    await streamClient.currentUser!.profile();
    return user;
  }
  return Future.value();
});

and the function where I first get a user:

widget.streamClient.currentUser!.get().then((value) {
      var data = value.data;
      
      setState(() {
        image = data!['photo'] as String;
        name = data['name'] as String;
      });
      fetchStories();
    });

@xsahil03x

from stream-feed-flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.