Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions flutter/lib/common/hbbs/hbbs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum UserStatus { kDisabled, kNormal, kUnverified }
// Is all the fields of the user needed?
class UserPayload {
String name = '';
String displayName = '';
String email = '';
String note = '';
String? verifier;
Expand All @@ -33,6 +34,7 @@ class UserPayload {

UserPayload.fromJson(Map<String, dynamic> json)
: name = json['name'] ?? '',
displayName = json['display_name'] ?? '',
email = json['email'] ?? '',
note = json['note'] ?? '',
verifier = json['verifier'],
Expand All @@ -46,6 +48,7 @@ class UserPayload {
Map<String, dynamic> toJson() {
final Map<String, dynamic> map = {
'name': name,
'display_name': displayName,
'status': status == UserStatus.kDisabled
? 0
: status == UserStatus.kUnverified
Expand All @@ -58,9 +61,14 @@ class UserPayload {
Map<String, dynamic> toGroupCacheJson() {
final Map<String, dynamic> map = {
'name': name,
'display_name': displayName,
};
return map;
}

String get displayNameOrName {
return displayName.trim().isEmpty ? name : displayName;
}
}

class PeerPayload {
Expand Down
29 changes: 21 additions & 8 deletions flutter/lib/common/widgets/my_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,18 @@ class _MyGroupState extends State<MyGroup> {
return Obx(() {
final userItems = gFFI.groupModel.users.where((p0) {
if (searchAccessibleItemNameText.isNotEmpty) {
return p0.name
.toLowerCase()
.contains(searchAccessibleItemNameText.value.toLowerCase());
final search = searchAccessibleItemNameText.value.toLowerCase();
return p0.name.toLowerCase().contains(search) ||
p0.displayNameOrName.toLowerCase().contains(search);
}
return true;
}).toList();
// Count occurrences of each displayNameOrName to detect duplicates
final displayNameCount = <String, int>{};
for (final u in userItems) {
final dn = u.displayNameOrName;
displayNameCount[dn] = (displayNameCount[dn] ?? 0) + 1;
}
final deviceGroupItems = gFFI.groupModel.deviceGroups.where((p0) {
if (searchAccessibleItemNameText.isNotEmpty) {
return p0.name
Expand All @@ -177,16 +183,23 @@ class _MyGroupState extends State<MyGroup> {
itemCount: deviceGroupItems.length + userItems.length,
itemBuilder: (context, index) => index < deviceGroupItems.length
? _buildDeviceGroupItem(deviceGroupItems[index])
: _buildUserItem(userItems[index - deviceGroupItems.length]));
: _buildUserItem(userItems[index - deviceGroupItems.length],
displayNameCount));
var maxHeight = max(MediaQuery.of(context).size.height / 6, 100.0);
return Obx(() => stateGlobal.isPortrait.isFalse
? listView(false)
: LimitedBox(maxHeight: maxHeight, child: listView(true)));
});
}

Widget _buildUserItem(UserPayload user) {
Widget _buildUserItem(UserPayload user, Map<String, int> displayNameCount) {
final username = user.name;
final dn = user.displayNameOrName;
final isDuplicate = (displayNameCount[dn] ?? 0) > 1;
final displayName =
isDuplicate && user.displayName.trim().isNotEmpty
? '${user.displayName} (@$username)'
: dn;
return InkWell(onTap: () {
isSelectedDeviceGroup.value = false;
if (selectedAccessibleItemName.value != username) {
Expand Down Expand Up @@ -222,14 +235,14 @@ class _MyGroupState extends State<MyGroup> {
alignment: Alignment.center,
child: Center(
child: Text(
username.characters.first.toUpperCase(),
displayName.characters.first.toUpperCase(),
style: TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
),
),
).marginOnly(right: 4),
if (isMe) Flexible(child: Text(username)),
if (isMe) Flexible(child: Text(displayName)),
if (isMe)
Flexible(
child: Container(
Expand All @@ -246,7 +259,7 @@ class _MyGroupState extends State<MyGroup> {
),
),
),
if (!isMe) Expanded(child: Text(username)),
if (!isMe) Expanded(child: Text(displayName)),
],
).paddingSymmetric(vertical: 4),
),
Expand Down
13 changes: 8 additions & 5 deletions flutter/lib/common/widgets/peers_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,14 @@ class MyGroupPeerView extends BasePeersView {
static bool filter(Peer peer) {
final model = gFFI.groupModel;
if (model.searchAccessibleItemNameText.isNotEmpty) {
final text = model.searchAccessibleItemNameText.value;
final searchPeersOfUser = peer.loginName.contains(text) &&
model.users.any((user) => user.name == peer.loginName);
final searchPeersOfDeviceGroup = peer.device_group_name.contains(text) &&
model.deviceGroups.any((g) => g.name == peer.device_group_name);
final text = model.searchAccessibleItemNameText.value.toLowerCase();
final searchPeersOfUser = model.users.any((user) =>
user.name == peer.loginName &&
(user.name.toLowerCase().contains(text) ||
user.displayNameOrName.toLowerCase().contains(text)));
final searchPeersOfDeviceGroup =
peer.device_group_name.toLowerCase().contains(text) &&
model.deviceGroups.any((g) => g.name == peer.device_group_name);
if (!searchPeersOfUser && !searchPeersOfDeviceGroup) {
return false;
}
Expand Down
12 changes: 10 additions & 2 deletions flutter/lib/desktop/pages/desktop_setting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,9 @@ class _AccountState extends State<_Account> {

Widget accountAction() {
return Obx(() => _Button(
gFFI.userModel.userName.value.isEmpty ? 'Login' : 'Logout',
gFFI.userModel.userName.value.isEmpty
? 'Login'
: '${translate('Logout')} (${gFFI.userModel.accountLabelWithHandle})',
() => {
gFFI.userModel.userName.value.isEmpty
? loginDialog()
Expand All @@ -2037,6 +2039,10 @@ class _AccountState extends State<_Account> {
offstage: gFFI.userModel.userName.value.isEmpty,
child: Column(
children: [
if (gFFI.userModel.displayName.value.trim().isNotEmpty &&
gFFI.userModel.displayName.value.trim() !=
gFFI.userModel.userName.value.trim())
text('Display Name', gFFI.userModel.displayName.value.trim()),
text('Username', gFFI.userModel.userName.value),
// text('Group', gFFI.groupModel.groupName.value),
],
Expand Down Expand Up @@ -2130,7 +2136,9 @@ class _PluginState extends State<_Plugin> {

Widget accountAction() {
return Obx(() => _Button(
gFFI.userModel.userName.value.isEmpty ? 'Login' : 'Logout',
gFFI.userModel.userName.value.isEmpty
? 'Login'
: '${translate('Logout')} (${gFFI.userModel.accountLabelWithHandle})',
() => {
gFFI.userModel.userName.value.isEmpty
? loginDialog()
Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/mobile/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
SettingsTile(
title: Obx(() => Text(gFFI.userModel.userName.value.isEmpty
? translate('Login')
: '${translate('Logout')} (${gFFI.userModel.userName.value})')),
: '${translate('Logout')} (${gFFI.userModel.accountLabelWithHandle})')),
leading: Icon(Icons.person),
onPressed: (context) {
if (gFFI.userModel.userName.value.isEmpty) {
Expand Down
19 changes: 18 additions & 1 deletion flutter/lib/models/user_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,23 @@ bool refreshingUser = false;

class UserModel {
final RxString userName = ''.obs;
final RxString displayName = ''.obs;
final RxBool isAdmin = false.obs;
final RxString networkError = ''.obs;
bool get isLogin => userName.isNotEmpty;
String get displayNameOrUserName =>
displayName.value.trim().isEmpty ? userName.value : displayName.value;
String get accountLabelWithHandle {
final username = userName.value.trim();
if (username.isEmpty) {
return '';
}
final preferred = displayName.value.trim();
if (preferred.isEmpty || preferred == username) {
return username;
}
return '$preferred (@$username)';
}
WeakReference<FFI> parent;

UserModel(this.parent) {
Expand Down Expand Up @@ -98,7 +112,8 @@ class UserModel {
_updateLocalUserInfo() {
final userInfo = getLocalUserInfo();
if (userInfo != null) {
userName.value = userInfo['name'];
userName.value = (userInfo['name'] ?? '').toString();
displayName.value = (userInfo['display_name'] ?? '').toString();
}
}

Expand All @@ -110,10 +125,12 @@ class UserModel {
await gFFI.groupModel.reset();
}
userName.value = '';
displayName.value = '';
}

_parseAndUpdateUser(UserPayload user) {
userName.value = user.name;
displayName.value = user.displayName;
isAdmin.value = user.isAdmin;
bind.mainSetLocalOption(key: 'user_info', value: jsonEncode(user));
if (isWeb) {
Expand Down
2 changes: 1 addition & 1 deletion libs/hbb_common
Submodule hbb_common updated 1 files
+6 −0 src/config.rs
4 changes: 3 additions & 1 deletion res/msi/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,9 @@ def func(lines, index_start):
f'{indent}<RegistryValue Type="integer" Name="Language" Value="[ProductLanguage]" />\n'
)

estimated_size = get_folder_size(dist_dir)
# EstimatedSize in uninstall registry must be in KB.
estimated_size_bytes = get_folder_size(dist_dir)
estimated_size = max(1, (estimated_size_bytes + 1023) // 1024)
lines_new.append(
f'{indent}<RegistryValue Type="integer" Name="EstimatedSize" Value="{estimated_size}" />\n'
)
Expand Down
9 changes: 6 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2630,10 +2630,13 @@ impl LoginConfigHandler {
display_name =
serde_json::from_str::<serde_json::Value>(&LocalConfig::get_option("user_info"))
.map(|x| {
x.get("name")
.map(|x| x.as_str().unwrap_or_default())
x.get("display_name")
.and_then(|x| x.as_str())
.map(|x| x.trim())
.filter(|x| !x.is_empty())
.or_else(|| x.get("name").and_then(|x| x.as_str()))
.map(|x| x.to_owned())
.unwrap_or_default()
.to_owned()
})
.unwrap_or_default();
}
Expand Down
9 changes: 8 additions & 1 deletion src/hbbs_http/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ pub enum UserStatus {
pub struct UserPayload {
pub name: String,
#[serde(default)]
pub display_name: Option<String>,
#[serde(default)]
pub email: Option<String>,
#[serde(default)]
pub note: Option<String>,
Expand Down Expand Up @@ -268,7 +270,12 @@ impl OidcSession {
);
LocalConfig::set_option(
"user_info".to_owned(),
serde_json::json!({ "name": auth_body.user.name, "status": auth_body.user.status }).to_string(),
serde_json::json!({
"name": auth_body.user.name,
"display_name": auth_body.user.display_name,
"status": auth_body.user.status
})
.to_string(),
);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/lang/ar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "متابعة مع {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/be.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "Працягнуць з {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/bg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "Продължи с {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/ca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "Continua amb {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/cn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "使用 {} 登录"),
("Display Name", "显示名称"),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "Pokračovat s {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/da.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "Fortsæt med {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", "Bildschirm während ausgehender Sitzungen aktiv halten"),
("keep-awake-during-incoming-sessions-label", "Bildschirm während eingehender Sitzungen aktiv halten"),
("Continue with {}", "Fortfahren mit {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/el.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "Συνέχεια με {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/eo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", ""),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/es.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "Continuar con {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/et.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "Jätka koos {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/eu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "{} honekin jarraitu"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/fa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "ادامه با {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/fi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "Jatka käyttäen {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/fr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", "Maintenir l’écran allumé lors des sessions sortantes"),
("keep-awake-during-incoming-sessions-label", "Maintenir l’écran allumé lors des sessions entrantes"),
("Continue with {}", "Continuer avec {}"),
("Display Name", ""),
].iter().cloned().collect();
}
1 change: 1 addition & 0 deletions src/lang/ge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("keep-awake-during-outgoing-sessions-label", ""),
("keep-awake-during-incoming-sessions-label", ""),
("Continue with {}", "{}-ით გაგრძელება"),
("Display Name", ""),
].iter().cloned().collect();
}
Loading
Loading