Skip to content

Commit 74f62d9

Browse files
committed
feat: daily update
1 parent 7415542 commit 74f62d9

File tree

33 files changed

+481
-215
lines changed

33 files changed

+481
-215
lines changed
544 Bytes
Loading

lib/imports.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export 'models/assistant.dart';
5252
export 'models/attribute.dart';
5353
export 'models/cache.dart';
5454
export 'models/canned_response.dart';
55-
export 'models/common.dart';
5655
export 'models/contact.dart';
5756
export 'models/conversation.dart';
5857
export 'models/file.dart';

lib/l10n/app_en.arb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
"change_password_confirm": "Confirm new password",
159159
"change_password_confirm_hint": "Please re-enter your new password",
160160
"change_password_mismatch": "Confirm password should match the password",
161+
"change_password_successful": "change_password_successful",
161162
"labels": "Labels",
162163
"labels_description": "Labels help you categorize and prioritize conversations and leads. You can assign a label to a conversation or contact using the side panel.",
163164
"labels_add": "Add label",
@@ -225,6 +226,11 @@
225226
"notification_new_message_push": "You are mentioned in a conversation",
226227
"notification_mention_push": "A new message is created in an assigned conversation",
227228
"notification_participating_new_message_push": "A new message is created in a participating conversation",
229+
"notification_content_conversation_creation": "New conversation created",
230+
"notification_content_conversation_assignment": "A conversation has been assigned to you",
231+
"notification_content_assigned_conversation_new_message": "New message in an assigned conversation",
232+
"notification_content_conversation_mention": "You have been mentioned in a conversation",
233+
"notification_content_participating_conversation_new_message": "New message in a conversation you are participating in",
228234
"cancel": "Cancel",
229235
"delete": "Delete",
230236
"oldest": "Oldest",
@@ -299,5 +305,8 @@
299305
"assignee": "Assignee",
300306
"actions": "Actions",
301307
"location": "Location",
302-
"phone": "Phone"
308+
"phone": "Phone",
309+
"call": "Call",
310+
"message": "Message",
311+
"profile_update_successful": "profile_update_successful"
303312
}

lib/main.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ void main() async {
5050
}
5151

5252
// logger
53-
var appDocumentsDir = await getApplicationCacheDirectory();
54-
var logPath = p.join(appDocumentsDir.path, 'logs');
53+
final appDocumentsDir = await getApplicationCacheDirectory();
54+
final logPath = p.join(appDocumentsDir.path, 'logs');
5555
logger.Logger.level = kDebugMode ? logger.Level.debug : logger.Level.info;
5656
logger.Logger.defaultPrinter = () {
5757
return PrettyPrinter();
@@ -67,11 +67,10 @@ void main() async {
6767
// window
6868
if (GetPlatform.isDesktop) {
6969
await windowManager.ensureInitialized();
70-
var windowOptions = WindowOptions(
70+
final windowOptions = WindowOptions(
7171
size: const Size(1280, 720),
7272
minimumSize: const Size(1080, 640),
7373
center: true,
74-
titleBarStyle: TitleBarStyle.hidden,
7574
);
7675
windowManager.waitUntilReadyToShow(windowOptions, () async {
7776
await windowManager.show();

lib/models/common.dart

Lines changed: 0 additions & 55 deletions
This file was deleted.

lib/models/conversation.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import '/imports.dart';
22
import 'package:intl/intl.dart';
33

44
class ConversationMeta {
5-
final SenderInfo sender;
5+
final UserInfo sender;
66
final InboxChannelType? channel;
77
final UserInfo? assignee;
88
final TeamInfo? team;
@@ -25,7 +25,7 @@ class ConversationMeta {
2525
: null;
2626

2727
return ConversationMeta(
28-
sender: SenderInfo.fromJson(json['sender']),
28+
sender: UserInfo.fromJson(json['sender']),
2929
channel: channel,
3030
assignee: assignee,
3131
team: team,

lib/models/notification.dart

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import '/imports.dart';
22

33
class NotificationPrimaryActorMeta {
4-
final SenderInfo sender;
4+
final UserInfo sender;
55

66
const NotificationPrimaryActorMeta({
77
required this.sender,
88
});
99

1010
factory NotificationPrimaryActorMeta.fromJson(dynamic json) {
1111
return NotificationPrimaryActorMeta(
12-
sender: SenderInfo.fromJson(json['sender']),
12+
sender: UserInfo.fromJson(json['sender']),
1313
);
1414
}
15+
16+
Map<String, dynamic> toJson() {
17+
return {
18+
'sender': sender.toJson(),
19+
};
20+
}
1521
}
1622

1723
class NotificationPrimaryActor {
@@ -26,6 +32,12 @@ class NotificationPrimaryActor {
2632
meta: NotificationPrimaryActorMeta.fromJson(json['meta']),
2733
);
2834
}
35+
36+
Map<String, dynamic> toJson() {
37+
return {
38+
'meta': meta.toJson(),
39+
};
40+
}
2941
}
3042

3143
class NotificationInfo {
@@ -41,7 +53,7 @@ class NotificationInfo {
4153
final DateTime created_at;
4254
final DateTime last_activity_at;
4355
final dynamic snoozed_until; // TODO: unk type
44-
final dynamic meta;
56+
final dynamic meta; // TODO: unk type
4557

4658
NotificationInfo({
4759
required this.id,
@@ -83,6 +95,24 @@ class NotificationInfo {
8395
meta: json['meta'],
8496
);
8597
}
98+
99+
Map<String, dynamic> toJson() {
100+
return {
101+
'id': id,
102+
'notification_type': notification_type.name,
103+
'push_message_title': push_message_title,
104+
'primary_actor_type': primary_actor_type.name,
105+
'primary_actor_id': primary_actor_id,
106+
'primary_actor': primary_actor.toJson(),
107+
'read_at': read_at.toString(),
108+
'secondary_actor': secondary_actor,
109+
'user': user?.toJson(),
110+
'created_at': created_at.toString(),
111+
'last_activity_at': last_activity_at.toString(),
112+
'snoozed_until': snoozed_until,
113+
'meta': meta,
114+
};
115+
}
86116
}
87117

88118
class ListNotificationMeta extends ApiListMeta {

lib/models/user.dart

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class UserInfo {
55
final int? account_id;
66
final String name;
77
final String available_name;
8-
final AvailabilityStatus? availability_status;
8+
final AvailabilityStatus availability_status;
99
final bool? auto_offline;
1010
final bool? confirmed;
1111
final String thumbnail;
@@ -17,13 +17,15 @@ class UserInfo {
1717
this.account_id,
1818
required this.name,
1919
String? available_name,
20-
this.availability_status,
20+
AvailabilityStatus? availability_status,
2121
required this.thumbnail,
2222
this.auto_offline,
2323
this.confirmed,
2424
this.custom_role_id,
2525
required this.type,
26-
}) : available_name = available_name ?? name;
26+
}) : available_name = available_name ?? name,
27+
availability_status =
28+
availability_status ?? AvailabilityStatus.undefined;
2729

2830
factory UserInfo.fromJson(dynamic json) {
2931
return UserInfo(
@@ -40,4 +42,18 @@ class UserInfo {
4042
type: UserType.fromName(json['type']),
4143
);
4244
}
45+
46+
Map<String, dynamic> toJson() {
47+
return {
48+
'id': id,
49+
'account_id': account_id,
50+
'available_name': available_name,
51+
'availability_status': availability_status.name,
52+
'thumbnail': thumbnail,
53+
'auto_offline': auto_offline,
54+
'confirmed': confirmed,
55+
'custom_role_id': custom_role_id,
56+
'type': type.name,
57+
};
58+
}
4359
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
11
import '/imports.dart';
22

33
class AgentsController extends GetxController {
4+
final _logger = Logger();
5+
final _api = Get.find<ApiService>();
6+
final _auth = Get.find<AuthService>();
7+
final items = RxList<UserInfo>();
8+
9+
@override
10+
void onReady() {
11+
super.onReady();
12+
13+
_auth.profile.listen((next) {
14+
if (next == null) return;
15+
getAgents();
16+
});
17+
18+
if (_auth.isSignedIn.value) getAgents();
19+
}
20+
421
Future<AgentsController> init() async {
522
return this;
623
}
24+
25+
Future<void> getAgents() async {
26+
try {
27+
final result = await _api.listAgents();
28+
items.value = result.getOrThrow();
29+
_logger.d('found ${items.length} items');
30+
} catch (error) {
31+
errorHandler(error);
32+
}
33+
}
734
}

lib/screens/agents/views/index.dart

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import '../controllers/index.dart';
21
import '/imports.dart';
32

43
class AgentsView extends GetView<AgentsController> {
4+
final realtime = Get.find<RealtimeService>();
55
late final AgentsController c;
66
AgentsView({super.key}) : c = Get.put(AgentsController());
77

@@ -27,22 +27,32 @@ class AgentsView extends GetView<AgentsController> {
2727
),
2828
),
2929
),
30-
SliverList(
31-
delegate: SliverChildBuilderDelegate(
32-
(_, int index) {
33-
return ListTile(
34-
leading: Container(
35-
padding: EdgeInsets.all(8),
36-
width: 100,
37-
child: Placeholder()),
38-
title: Text('Place ${index + 1}'),
39-
);
40-
},
41-
childCount: 20,
42-
),
43-
),
30+
Obx(() {
31+
final items = c.items.value;
32+
33+
return SliverList(
34+
delegate: SliverChildBuilderDelegate(
35+
(_, i) => buildItem(context, items[i]),
36+
childCount: items.length,
37+
),
38+
);
39+
}),
4440
],
4541
),
4642
);
4743
}
44+
45+
Widget buildItem(BuildContext context, UserInfo info) {
46+
return CustomListTile(
47+
leading: Obx(() {
48+
return avatar(
49+
context,
50+
url: info.thumbnail,
51+
isOnline: realtime.online.value.contains(info.id),
52+
fallback: info.name.substring(0, 1),
53+
);
54+
}),
55+
title: Text(info.name),
56+
);
57+
}
4858
}

0 commit comments

Comments
 (0)