-
Notifications
You must be signed in to change notification settings - Fork 976
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from mylxsw/develop
Develop
- Loading branch information
Showing
25 changed files
with
1,486 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ jobs: | |
- name: Set up Flutter | ||
uses: subosito/[email protected] | ||
with: | ||
flutter-version: "3.13.2" # Set flutter version here | ||
flutter-version: "3.19.2" # Set flutter version here | ||
|
||
- name: Build Windows app | ||
#run: flutter build windows --release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import 'package:askaide/repo/api/page.dart'; | ||
import 'package:askaide/repo/api_server.dart'; | ||
import 'package:askaide/repo/model/message.dart'; | ||
import 'package:askaide/repo/model/misc.dart'; | ||
import 'package:bloc/bloc.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
part 'admin_room_event.dart'; | ||
part 'admin_room_state.dart'; | ||
|
||
class AdminRoomBloc extends Bloc<AdminRoomEvent, AdminRoomState> { | ||
AdminRoomBloc() : super(AdminRoomInitial()) { | ||
on<AdminRoomsLoadEvent>((event, emit) async { | ||
final rooms = await APIServer().adminUserRooms(userId: event.userId); | ||
emit(AdminRoomsLoaded(rooms: rooms)); | ||
}); | ||
|
||
on<AdminRoomLoadEvent>((event, emit) async { | ||
final room = await APIServer().adminUserRoom( | ||
userId: event.userId, | ||
roomId: event.roomId, | ||
); | ||
emit(AdminRoomLoaded(room: room)); | ||
}); | ||
|
||
on<AdminRoomRecentlyMessagesLoadEvent>((event, emit) async { | ||
if (event.roomType == 4) { | ||
final messages = await APIServer().adminUserRoomGroupMessages( | ||
userId: event.userId, roomId: event.roomId); | ||
emit(AdminRoomRecentlyMessagesLoaded( | ||
messages: messages | ||
.map((e) => Message( | ||
e.role == 'user' ? Role.sender : Role.receiver, | ||
e.message, | ||
type: MessageType.text, | ||
ts: e.createdAt, | ||
model: e.model, | ||
quotaConsumed: e.quotaConsumed, | ||
tokenConsumed: e.tokenConsumed, | ||
refId: e.pid, | ||
id: e.id, | ||
serverId: e.id, | ||
)) | ||
.toList())); | ||
} else { | ||
final messages = await APIServer().adminUserRoomMessages( | ||
userId: event.userId, | ||
roomId: event.roomId, | ||
); | ||
emit(AdminRoomRecentlyMessagesLoaded( | ||
messages: messages | ||
.map((e) => Message( | ||
e.role == 1 ? Role.sender : Role.receiver, | ||
e.message, | ||
type: MessageType.text, | ||
ts: e.createdAt, | ||
model: e.model, | ||
quotaConsumed: e.quotaConsumed, | ||
tokenConsumed: e.tokenConsumed, | ||
refId: e.pid, | ||
id: e.id, | ||
serverId: e.id, | ||
userId: e.userId, | ||
roomId: e.roomId, | ||
)) | ||
.toList())); | ||
} | ||
}); | ||
|
||
on<AdminRecentlyMessagesLoadEvent>((event, emit) async { | ||
final messages = await APIServer().adminRecentlyMessages( | ||
page: event.page, | ||
perPage: event.perPage, | ||
keyword: event.keyword, | ||
); | ||
emit(AdminRecentlyMessagesLoaded(PagedData( | ||
data: messages.data | ||
.map((e) => Message( | ||
e.role == 1 ? Role.sender : Role.receiver, | ||
e.message, | ||
type: MessageType.text, | ||
ts: e.createdAt, | ||
model: e.model, | ||
quotaConsumed: e.quotaConsumed, | ||
tokenConsumed: e.tokenConsumed, | ||
refId: e.pid, | ||
id: e.id, | ||
serverId: e.id, | ||
userId: e.userId, | ||
roomId: e.roomId, | ||
)) | ||
.toList(), | ||
page: messages.page, | ||
perPage: messages.perPage, | ||
total: messages.total, | ||
lastPage: messages.lastPage, | ||
))); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
part of 'admin_room_bloc.dart'; | ||
|
||
@immutable | ||
sealed class AdminRoomEvent {} | ||
|
||
class AdminRoomsLoadEvent extends AdminRoomEvent { | ||
final int userId; | ||
|
||
AdminRoomsLoadEvent({required this.userId}); | ||
} | ||
|
||
class AdminRoomLoadEvent extends AdminRoomEvent { | ||
final int userId; | ||
final int roomId; | ||
|
||
AdminRoomLoadEvent({required this.roomId, required this.userId}); | ||
} | ||
|
||
class AdminRoomRecentlyMessagesLoadEvent extends AdminRoomEvent { | ||
final int userId; | ||
final int roomId; | ||
final int roomType; | ||
|
||
AdminRoomRecentlyMessagesLoadEvent({ | ||
required this.roomId, | ||
required this.userId, | ||
required this.roomType, | ||
}); | ||
} | ||
|
||
class AdminRecentlyMessagesLoadEvent extends AdminRoomEvent { | ||
final int page; | ||
final int perPage; | ||
final String? keyword; | ||
|
||
AdminRecentlyMessagesLoadEvent({ | ||
required this.page, | ||
required this.perPage, | ||
this.keyword, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
part of 'admin_room_bloc.dart'; | ||
|
||
@immutable | ||
sealed class AdminRoomState {} | ||
|
||
final class AdminRoomInitial extends AdminRoomState {} | ||
|
||
final class AdminRoomsLoaded extends AdminRoomState { | ||
final List<RoomInServer> rooms; | ||
|
||
AdminRoomsLoaded({required this.rooms}); | ||
} | ||
|
||
final class AdminRoomLoaded extends AdminRoomState { | ||
final RoomInServer room; | ||
|
||
AdminRoomLoaded({required this.room}); | ||
} | ||
|
||
final class AdminRoomRecentlyMessagesLoaded extends AdminRoomState { | ||
final List<Message> messages; | ||
|
||
AdminRoomRecentlyMessagesLoaded({required this.messages}); | ||
} | ||
|
||
class AdminRoomOperationResult extends AdminRoomState { | ||
final bool success; | ||
final String message; | ||
|
||
AdminRoomOperationResult(this.success, this.message); | ||
} | ||
|
||
class AdminRecentlyMessagesLoaded extends AdminRoomState { | ||
final PagedData<Message> messages; | ||
|
||
AdminRecentlyMessagesLoaded(this.messages); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.