Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat creator role is null instead of admin #20

Closed
Parfyonator opened this issue Nov 20, 2024 · 5 comments · Fixed by #19
Closed

Chat creator role is null instead of admin #20

Parfyonator opened this issue Nov 20, 2024 · 5 comments · Fixed by #19
Assignees
Labels
bug Something isn't working

Comments

@Parfyonator
Copy link

General

What bug do you experience? 🐞

When creating a group room the default role for the user creating a chat is 'admin' but in reality it turns out to be null as for all other users.

How can it be reproduced? 🤔

Create a group chat room using createGroupRoom method and check userRoles column for the corresponding chat room in Supabase project in chats.rooms table.

What behaviour is expected? 💡

Set the default role for chat creator to be 'admin'.


Extras

Screenshots or videos 📸

If applicable, add screenshots or videos to help explain your problem.

Code snippets 📝

Fix suggestion: add the following line after fetchUser in createGroupRoom method.

currentUser['role'] = creatorRole.toShortString();

Although role is being passed to fetchUser but it is not used there.


Environment info

Please specify the flutter, flutter_supabase_chat_core versions.

flutter: 3.22.0
flutter_supabase_chat_core: 1.1.0

flutter doctor -v output 👇

[!] Flutter (Channel stable, 3.22.0, on macOS 14.6.1 23G93 darwin-arm64, locale en-UA)
    • Flutter version 3.22.0 on channel stable at /Users/parf/fvm/versions/3.22.0
    ! The flutter binary is not on your path. Consider adding /Users/parf/fvm/versions/3.22.0/bin to your path.
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.18.2/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/parf/fvm/versions/3.22.0. Consider adding /Users/parf/fvm/versions/3.22.0/bin to the front of your
      path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dcb86f68f (7 months ago), 2024-05-09 07:39:20 -0500
    • Engine revision f6344b75dc
    • Dart version 3.4.0
    • DevTools version 2.34.3
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/parf/Library/Android/sdk
    • Platform android-34, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.95.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.100.0

[✓] Connected device (4 available)
    • EB2103 (mobile)                 • a6a5b622              • android-arm64  • Android 13 (API 33)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 131.0.6778.70
    ! Error: Browsing on the local area network for Oleksandr Parfionov’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Platform

Device (e.g. Android emulator, iOS simulator, Samsung Galaxy S21): all platforms

OS version (e.g. iOS 14.5, Android 11): any version


Additional context

Add any other context about the problem here.

@Parfyonator Parfyonator added the bug Something isn't working label Nov 20, 2024
@rickypid
Copy link
Contributor

Hi @Parfyonator,

Thanks for reporting this bug, I fixed it here #19, in the next few days I will release this new release.

@rickypid rickypid self-assigned this Nov 20, 2024
@rickypid rickypid mentioned this issue Nov 20, 2024
@Parfyonator
Copy link
Author

Hi @rickypid. Thanks for the latest update. Really excited to test if the user status is working now.

Unfortunately I cannot confirm I still had to do the following modification here for it to work:

final roomUsers = [loggedUser!.copyWith(role: creatorRole)] + users;

Also I'm experiencing strange behaviour. All user roles are null for every room, although they are clearly not in the database and I can confirm that the data from database is correct by printing userRoles from here:

print(userRoles);

Output: {441a5349-8a01-44a3-9fcd-1db35a07ab2b: admin, 7cf16ad4-8e43-4681-ba38-ffc456d22f98: null, 827895bf-0336-418a-8cad-add0b25e4926: null}

But when I print roles here I get an array of nulls:

print(users.map((u) => u['role']).toList());

Output: [null, null, null]

@rickypid
Copy link
Contributor

Sorry for the little bug, I didn't notice it, reading the users objects coming from the view I didn't parse the roles correctly. try #21

@Parfyonator
Copy link
Author

Just tried it. Seems to work fine now.

Thanks for help!

rickypid added a commit that referenced this issue Nov 22, 2024
@rickypid
Copy link
Contributor

Released, thanks for the support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants