Skip to content

Commit 9f2985b

Browse files
rickypidriccardocucia
andauthored
Fixed #20 Chat creator role is null instead of admin (#21)
Co-authored-by: riccardocucia <[email protected]>
1 parent d1b72c7 commit 9f2985b

File tree

7 files changed

+2738
-744
lines changed

7 files changed

+2738
-744
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [1.4.1] - 2024-11-21
2+
#### [@rickypid](https://github.com/rickypid)
3+
#### [@Parfyonator](https://github.com/Parfyonator)
4+
5+
### Fixed
6+
7+
* Fixed #20 Chat creator role is null instead of admin
8+
19
## [1.4.0] - 2024-11-21
210
#### [@rickypid](https://github.com/rickypid)
311

doc/package-lock.json

Lines changed: 2715 additions & 733 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flutter-supabase-chat-core",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"private": true,
55
"scripts": {
66
"docusaurus": "docusaurus",
@@ -15,18 +15,18 @@
1515
"typecheck": "tsc"
1616
},
1717
"dependencies": {
18-
"@docusaurus/core": "3.6.0",
19-
"@docusaurus/preset-classic": "3.6.0",
18+
"@docusaurus/core": "3.6.2",
19+
"@docusaurus/preset-classic": "3.6.2",
2020
"@mdx-js/react": "^3.1.0",
2121
"clsx": "^2.1.1",
2222
"prism-react-renderer": "^2.4.0",
2323
"react": "^18.3.1",
2424
"react-dom": "^18.3.1"
2525
},
2626
"devDependencies": {
27-
"@docusaurus/module-type-aliases": "3.6.0",
28-
"@docusaurus/tsconfig": "3.6.0",
29-
"@docusaurus/types": "3.6.0",
27+
"@docusaurus/module-type-aliases": "3.6.2",
28+
"@docusaurus/tsconfig": "3.6.2",
29+
"@docusaurus/types": "3.6.2",
3030
"typescript": "~5.6.3"
3131
},
3232
"browserslist": {

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: example
22
description: A new Flutter project.
33
publish_to: 'none'
44

5-
version: 1.4.0
5+
version: 1.4.1
66

77
environment:
88
sdk: '>=3.4.0 <4.0.0'

lib/src/class/supabase_chat_core.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class SupabaseChatCore {
174174
}) async {
175175
if (loggedSupabaseUser == null) return Future.error('User does not exist');
176176

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

179179
final room =
180180
await client.schema(config.schema).from(config.roomsTableName).insert({

lib/src/util.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ Future<types.Room> processRoomRow(
6666
final type = data['type'] as String;
6767
final userIds = data['userIds'] as List<dynamic>;
6868
final userRoles = data['userRoles'] as Map<String, dynamic>?;
69-
final users = data['users'] ??
69+
final users = data['users']?.map(
70+
(e) {
71+
e['role'] = userRoles?[e['id']];
72+
return e;
73+
},
74+
).toList() ??
7075
await Future.wait(
7176
userIds.map(
7277
(userId) => fetchUser(
@@ -78,7 +83,6 @@ Future<types.Room> processRoomRow(
7883
),
7984
),
8085
);
81-
8286
if (type == types.RoomType.direct.toShortString()) {
8387
final index = users.indexWhere(
8488
(u) => u['id'] != supabaseUser.id,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: flutter_supabase_chat_core
22
description: >
33
Actively maintained, community-driven Supabase BaaS for chat applications
44
with an optional chat UI.
5-
version: 1.4.0
5+
version: 1.4.1
66
homepage: https://flutter-supabase-chat-core.insideapp.it
77
repository: https://github.com/insideapp-srl/flutter_supabase_chat_core
88

0 commit comments

Comments
 (0)