Skip to content

Commit

Permalink
Fixed #20 Chat creator role is null instead of admin (#21)
Browse files Browse the repository at this point in the history
Co-authored-by: riccardocucia <riccardocucia@gmial.com>
  • Loading branch information
rickypid and riccardocucia authored Nov 22, 2024
1 parent d1b72c7 commit 9f2985b
Show file tree
Hide file tree
Showing 7 changed files with 2,738 additions and 744 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [1.4.1] - 2024-11-21
#### [@rickypid](https://github.com/rickypid)
#### [@Parfyonator](https://github.com/Parfyonator)

### Fixed

* Fixed #20 Chat creator role is null instead of admin

## [1.4.0] - 2024-11-21
#### [@rickypid](https://github.com/rickypid)

Expand Down
3,448 changes: 2,715 additions & 733 deletions doc/package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions doc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flutter-supabase-chat-core",
"version": "1.4.0",
"version": "1.4.1",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand All @@ -15,18 +15,18 @@
"typecheck": "tsc"
},
"dependencies": {
"@docusaurus/core": "3.6.0",
"@docusaurus/preset-classic": "3.6.0",
"@docusaurus/core": "3.6.2",
"@docusaurus/preset-classic": "3.6.2",
"@mdx-js/react": "^3.1.0",
"clsx": "^2.1.1",
"prism-react-renderer": "^2.4.0",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.6.0",
"@docusaurus/tsconfig": "3.6.0",
"@docusaurus/types": "3.6.0",
"@docusaurus/module-type-aliases": "3.6.2",
"@docusaurus/tsconfig": "3.6.2",
"@docusaurus/types": "3.6.2",
"typescript": "~5.6.3"
},
"browserslist": {
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: example
description: A new Flutter project.
publish_to: 'none'

version: 1.4.0
version: 1.4.1

environment:
sdk: '>=3.4.0 <4.0.0'
Expand Down
2 changes: 1 addition & 1 deletion lib/src/class/supabase_chat_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class SupabaseChatCore {
}) async {
if (loggedSupabaseUser == null) return Future.error('User does not exist');

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

final room =
await client.schema(config.schema).from(config.roomsTableName).insert({
Expand Down
8 changes: 6 additions & 2 deletions lib/src/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ Future<types.Room> processRoomRow(
final type = data['type'] as String;
final userIds = data['userIds'] as List<dynamic>;
final userRoles = data['userRoles'] as Map<String, dynamic>?;
final users = data['users'] ??
final users = data['users']?.map(
(e) {
e['role'] = userRoles?[e['id']];
return e;
},
).toList() ??
await Future.wait(
userIds.map(
(userId) => fetchUser(
Expand All @@ -78,7 +83,6 @@ Future<types.Room> processRoomRow(
),
),
);

if (type == types.RoomType.direct.toShortString()) {
final index = users.indexWhere(
(u) => u['id'] != supabaseUser.id,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_supabase_chat_core
description: >
Actively maintained, community-driven Supabase BaaS for chat applications
with an optional chat UI.
version: 1.4.0
version: 1.4.1
homepage: https://flutter-supabase-chat-core.insideapp.it
repository: https://github.com/insideapp-srl/flutter_supabase_chat_core

Expand Down

0 comments on commit 9f2985b

Please sign in to comment.