Skip to content

Commit

Permalink
Merge pull request #136 from mylxsw/v2.x
Browse files Browse the repository at this point in the history
V2.x
  • Loading branch information
mylxsw authored Feb 14, 2025
2 parents 8e47233 + 77f027d commit 561510b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 43 deletions.
9 changes: 3 additions & 6 deletions lib/bloc/room_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ class RoomBloc extends BlocExt<RoomEvent, RoomState> {
emit(RoomsLoading());

try {
int id = 0;
if (Ability().isUserLogon()) {
String? model;
String? vendor;
Expand All @@ -161,7 +160,7 @@ class RoomBloc extends BlocExt<RoomEvent, RoomState> {
vendor = event.model!.startsWith('v2@') ? '' : (segs.length > 1 ? segs.first : '');
}

id = await APIServer().createRoom(
await APIServer().createRoom(
name: event.name,
vendor: vendor,
model: model,
Expand All @@ -172,19 +171,17 @@ class RoomBloc extends BlocExt<RoomEvent, RoomState> {
initMessage: event.initMessage,
);
} else {
final room = await chatMsgRepo.createRoom(
await chatMsgRepo.createRoom(
name: event.name,
category: 'chat',
model: event.model ?? 'gpt-4o',
systemPrompt: event.prompt,
userId: APIServer().localUserID(),
maxContext: event.maxContext,
);

id = room.id!;
}

emit(RoomOperationResult(true, redirect: '/room/$id/chat'));
emit(RoomOperationResult(true));
emit(await createRoomsLoadedState(cache: false));
} catch (e) {
emit(RoomOperationResult(false, error: e.toString()));
Expand Down
2 changes: 2 additions & 0 deletions lib/page/chat/character_create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class _CharacterCreatePageState extends State<CharacterCreatePage> {
context.read<RoomBloc>().add(RoomsLoadEvent());
}
});
} else {
context.pop();
}
} else {
showErrorMessageEnhanced(context, state.error ?? AppLocale.operateFailed.getString(context));
Expand Down
76 changes: 39 additions & 37 deletions lib/page/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class _LeftDrawerState extends State<LeftDrawer> {
child: SizedBox(height: PlatformTool.isMacOS() ? kToolbarHeight : 20),
),

if (Ability().isUserLogon())
if (Ability().isUserLogon() && Ability().enableDigitalHuman)
ListTile(
leading: const Icon(Icons.group_outlined),
title: Text(AppLocale.homeTitle.getString(context)),
Expand All @@ -79,37 +79,38 @@ class _LeftDrawerState extends State<LeftDrawer> {
},
),

BlocBuilder<RoomBloc, RoomState>(
buildWhen: (previous, current) => current is RoomsRecentLoaded,
builder: (_, state) {
if (state is RoomsRecentLoaded) {
return ListView.builder(
shrinkWrap: true,
padding: const EdgeInsets.all(0),
physics: const NeverScrollableScrollPhysics(),
itemCount: state.rooms.length,
itemBuilder: (context, index) {
final item = state.rooms[index];
return ListTile(
contentPadding: const EdgeInsets.only(left: 30),
dense: true,
leading: RoleAvatar(
avatarUrl: item.avatarUrl,
name: item.name,
avatarSize: 25,
),
title: Text(item.name),
onTap: () {
context.push('/room/${item.id}/chat').whenComplete(reload);
},
);
},
);
}
if (Ability().isUserLogon() && Ability().enableDigitalHuman)
BlocBuilder<RoomBloc, RoomState>(
buildWhen: (previous, current) => current is RoomsRecentLoaded,
builder: (_, state) {
if (state is RoomsRecentLoaded) {
return ListView.builder(
shrinkWrap: true,
padding: const EdgeInsets.all(0),
physics: const NeverScrollableScrollPhysics(),
itemCount: state.rooms.length,
itemBuilder: (context, index) {
final item = state.rooms[index];
return ListTile(
contentPadding: const EdgeInsets.only(left: 30),
dense: true,
leading: RoleAvatar(
avatarUrl: item.avatarUrl,
name: item.name,
avatarSize: 25,
),
title: Text(item.name),
onTap: () {
context.push('/room/${item.id}/chat').whenComplete(reload);
},
);
},
);
}

return const SizedBox();
},
),
return const SizedBox();
},
),
if (Ability().enableGallery)
ListTile(
leading: const Icon(Icons.auto_awesome_outlined),
Expand All @@ -125,12 +126,13 @@ class _LeftDrawerState extends State<LeftDrawer> {
// context.push('/creative-draw');
// },
// ),
Divider(
color: customColors.weakTextColor?.withAlpha(50),
height: 10,
indent: 10,
endIndent: 10,
),
if (Ability().enableGallery || (Ability().isUserLogon() && Ability().enableDigitalHuman))
Divider(
color: customColors.weakTextColor?.withAlpha(50),
height: 10,
indent: 10,
endIndent: 10,
),
BlocBuilder<ChatChatBloc, ChatChatState>(
buildWhen: (previous, current) => current is ChatChatRecentHistoriesLoaded,
builder: (_, state) {
Expand Down

0 comments on commit 561510b

Please sign in to comment.