Skip to content

Commit 80e1e92

Browse files
authored
dev v1.2.0 (#15)
## [1.2.0] - 2024-10-31 #### [@rickypid](https://github.com/rickypid) ⚠️⚠️ **Some Breaking Changes** ⚠️⚠️ ### New features * Added Users list pagination and searchable * Added Users typing status ### Fixed * Fix database index e security fix on function
1 parent 4b5d150 commit 80e1e92

20 files changed

+1181
-856
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## [1.2.0] - 2024-10-31
2+
#### [@rickypid](https://github.com/rickypid)
3+
4+
⚠️⚠️ **Some Breaking Changes** ⚠️⚠️
5+
6+
### New features
7+
8+
* Added Users list pagination and searchable
9+
* Added Users typing status
10+
11+
### Fixed
12+
13+
* Fix database index e security fix on function
14+
115
## [1.1.0] - 2024-08-30
216
#### [@danbeech](https://github.com/danbeech)
317
#### [@rickypid](https://github.com/rickypid)

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,15 @@ Below are the features implemented for each platform:
255255
| Chat screen ||| 🟡 || 🟡 | 🟡 |
256256
| Search room | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 |
257257
| Search message | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 |
258-
| Search user | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 |
258+
| Search user | | | 🟡 | | 🟡 | 🟡 |
259259
| Upload image ||| 🟡 || 🟡 | 🟡 |
260260
| Preview image message ||| 🟡 || 🟡 | 🟡 |
261261
| Upload file ||| 🟡 || 🟡 | 🟡 |
262262
| Download file ||| 🟡 || 🟡 | 🟡 |
263263
| Users online status ||| 🟡 || 🟡 | 🟡 |
264264
| Chat messages pagination ||| 🟡 || 🟡 | 🟡 |
265+
| Users pagination ||| 🟡 || 🟡 | 🟡 |
266+
| Users typing status ||| 🟡 || 🟡 | 🟡 |
265267

266268
- ✅ Tested
267269
- 🟡 Supported but not tested

doc/docs/guides/supabse-trigges.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: supabase-triggers
33
title: Database Triggers
44
---
55

6-
This is an example of a triggers that sets room's `lastMessages` to the most recent message sent once recieved in Firestore.
6+
This is an example of a triggers that sets room's `lastMessages` to the most recent message sent once recieved in Supabase.
77

88
```sql
99
CREATE OR REPLACE FUNCTION chats.update_last_messages()

doc/package-lock.json

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

doc/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flutter-supabase-chat-core",
3-
"version": "1.0.0",
3+
"version": "1.2.0",
44
"private": true,
55
"scripts": {
66
"docusaurus": "docusaurus",
@@ -15,19 +15,19 @@
1515
"typecheck": "tsc"
1616
},
1717
"dependencies": {
18-
"@docusaurus/core": "3.4.0",
19-
"@docusaurus/preset-classic": "3.4.0",
20-
"@mdx-js/react": "^3.0.1",
18+
"@docusaurus/core": "3.5.2",
19+
"@docusaurus/preset-classic": "3.5.2",
20+
"@mdx-js/react": "^3.1.0",
2121
"clsx": "^2.1.1",
22-
"prism-react-renderer": "^2.3.1",
22+
"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.4.0",
28-
"@docusaurus/tsconfig": "3.4.0",
29-
"@docusaurus/types": "3.4.0",
30-
"typescript": "~5.4.5"
27+
"@docusaurus/module-type-aliases": "3.5.2",
28+
"@docusaurus/tsconfig": "3.5.2",
29+
"@docusaurus/types": "3.5.2",
30+
"typescript": "~5.6.3"
3131
},
3232
"browserslist": {
3333
"production": [

example/.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,5 @@ app.*.map.json
4343
/android/app/profile
4444
/android/app/release
4545

46-
# Firebase
47-
GoogleService-Info.plist
48-
google-services.json
49-
firebase_app_id_file.json
50-
5146
/lib/supabase_options_for_test.dart
5247
/lib/main_test.dart

example/lib/auth.dart

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -97,41 +97,6 @@ class _AuthScreenState extends State<AuthScreen> {
9797
}
9898
return null;
9999
},
100-
//headerWidget: const IntroWidget(),
101100
initialAuthMode: AuthMode.signup,
102101
);
103102
}
104-
105-
class IntroWidget extends StatelessWidget {
106-
const IntroWidget({super.key});
107-
108-
@override
109-
Widget build(BuildContext context) => const Column(
110-
children: [
111-
Text.rich(
112-
TextSpan(
113-
children: [
114-
TextSpan(
115-
text: 'You are trying to login/sign up on server hosted on ',
116-
),
117-
TextSpan(
118-
text: 'example.com',
119-
style: TextStyle(fontWeight: FontWeight.bold),
120-
),
121-
],
122-
),
123-
textAlign: TextAlign.justify,
124-
),
125-
Row(
126-
children: <Widget>[
127-
Expanded(child: Divider()),
128-
Padding(
129-
padding: EdgeInsets.all(8.0),
130-
child: Text('Authenticate'),
131-
),
132-
Expanded(child: Divider()),
133-
],
134-
),
135-
],
136-
);
137-
}

example/lib/chat.dart

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ class _ChatPageState extends State<ChatPage> {
3535
super.initState();
3636
}
3737

38+
@override
39+
void dispose() {
40+
_chatController.dispose();
41+
super.dispose();
42+
}
43+
3844
void _handleAttachmentPressed() {
3945
showModalBottomSheet<void>(
4046
context: context,
@@ -106,7 +112,7 @@ class _ChatPageState extends State<ChatPage> {
106112
uri: url,
107113
);
108114

109-
SupabaseChatCore.instance.sendMessage(message, widget.room.id);
115+
await SupabaseChatCore.instance.sendMessage(message, widget.room.id);
110116
_setAttachmentUploading(false);
111117
} finally {
112118
_setAttachmentUploading(false);
@@ -143,7 +149,7 @@ class _ChatPageState extends State<ChatPage> {
143149
uri: url,
144150
width: image.width.toDouble(),
145151
);
146-
SupabaseChatCore.instance.sendMessage(
152+
await SupabaseChatCore.instance.sendMessage(
147153
message,
148154
widget.room.id,
149155
);
@@ -182,8 +188,9 @@ class _ChatPageState extends State<ChatPage> {
182188
.updateMessage(updatedMessage, widget.room.id);
183189
}
184190

185-
void _handleSendPressed(types.PartialText message) {
186-
SupabaseChatCore.instance.sendMessage(
191+
Future<void> _handleSendPressed(types.PartialText message) async {
192+
await _chatController.endTyping();
193+
await SupabaseChatCore.instance.sendMessage(
187194
message,
188195
widget.room.id,
189196
);
@@ -204,30 +211,44 @@ class _ChatPageState extends State<ChatPage> {
204211
body: StreamBuilder<List<types.Message>>(
205212
initialData: const [],
206213
stream: _chatController.messages,
207-
builder: (context, snapshot) => Chat(
208-
showUserNames: true,
209-
showUserAvatars: true,
210-
isAttachmentUploading: _isAttachmentUploading,
211-
messages: snapshot.data ?? [],
212-
onAttachmentPressed: _handleAttachmentPressed,
213-
onMessageTap: _handleMessageTap,
214-
onPreviewDataFetched: _handlePreviewDataFetched,
215-
onSendPressed: _handleSendPressed,
216-
user: types.User(
217-
id: SupabaseChatCore.instance.supabaseUser!.id,
214+
builder: (context, messages) => StreamBuilder<List<types.User>>(
215+
initialData: const [],
216+
stream: _chatController.typingUsers,
217+
builder: (context, users) => Chat(
218+
showUserNames: true,
219+
showUserAvatars: true,
220+
theme: const DefaultChatTheme(
221+
messageMaxWidth: 600,
222+
),
223+
typingIndicatorOptions: TypingIndicatorOptions(
224+
typingUsers: users.data ?? [],
225+
),
226+
isAttachmentUploading: _isAttachmentUploading,
227+
messages: messages.data ?? [],
228+
onAttachmentPressed: _handleAttachmentPressed,
229+
onMessageTap: _handleMessageTap,
230+
onPreviewDataFetched: _handlePreviewDataFetched,
231+
onSendPressed: _handleSendPressed,
232+
user: types.User(
233+
id: SupabaseChatCore.instance.supabaseUser!.id,
234+
),
235+
imageHeaders: storageHeaders,
236+
onMessageVisibilityChanged: (message, visible) async {
237+
if (message.status != types.Status.seen &&
238+
message.author.id !=
239+
SupabaseChatCore.instance.supabaseUser!.id) {
240+
await SupabaseChatCore.instance.updateMessage(
241+
message.copyWith(status: types.Status.seen),
242+
widget.room.id,
243+
);
244+
}
245+
},
246+
onEndReached: _chatController.loadPreviousMessages,
247+
inputOptions: InputOptions(
248+
enabled: true,
249+
onTextChanged: (text) => _chatController.onTyping(),
250+
),
218251
),
219-
imageHeaders: storageHeaders,
220-
onMessageVisibilityChanged: (message, visible) async {
221-
if (message.status != types.Status.seen &&
222-
message.author.id !=
223-
SupabaseChatCore.instance.supabaseUser!.id) {
224-
await SupabaseChatCore.instance.updateMessage(
225-
message.copyWith(status: types.Status.seen),
226-
widget.room.id,
227-
);
228-
}
229-
},
230-
onEndReached: _chatController.loadPreviousMessages,
231252
),
232253
),
233254
);

example/lib/main.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ void main() async {
1212
url: supabaseOptions.url,
1313
anonKey: supabaseOptions.anonKey,
1414
);
15-
1615
runApp(const MyApp());
1716
}
1817

@@ -23,7 +22,7 @@ class MyApp extends StatelessWidget {
2322

2423
@override
2524
Widget build(BuildContext context) => MaterialApp(
26-
title: 'Firebase Chat',
25+
title: 'Supabase Chat',
2726
debugShowCheckedModeBanner: false,
2827
theme: ThemeData(
2928
useMaterial3: true,

example/lib/rooms.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ class _RoomsPageState extends State<RoomsPage> {
2424

2525
@override
2626
void initState() {
27-
initializeFlutterFire();
27+
initializeSupabase();
2828
super.initState();
2929
}
3030

31-
void initializeFlutterFire() async {
31+
void initializeSupabase() async {
3232
try {
3333
Supabase.instance.client.auth.onAuthStateChange.listen((data) {
3434
setState(() {
@@ -85,7 +85,6 @@ class _RoomsPageState extends State<RoomsPage> {
8585
);
8686
}
8787

88-
// Se `otherUser` non è null, la stanza è diretta e possiamo mostrare l'indicatore di stato online.
8988
return Container(
9089
margin: const EdgeInsets.only(right: 16),
9190
child: UserOnlineStatusWidget(
@@ -94,9 +93,7 @@ class _RoomsPageState extends State<RoomsPage> {
9493
alignment: Alignment.bottomRight,
9594
children: [
9695
child,
97-
if (status ==
98-
UserOnlineStatus
99-
.online) // Assumendo che `status` indichi lo stato online
96+
if (status == UserOnlineStatus.online)
10097
Container(
10198
width: 10,
10299
height: 10,

0 commit comments

Comments
 (0)