improve tab title selection
This commit is contained in:
@@ -45,11 +45,23 @@ class TabStates extends _$TabStates {
|
|||||||
void _onTabContentStateChange(TabContentState contentState) {
|
void _onTabContentStateChange(TabContentState contentState) {
|
||||||
final current =
|
final current =
|
||||||
state[contentState.id] ?? TabState.$default(contentState.id);
|
state[contentState.id] ?? TabState.$default(contentState.id);
|
||||||
|
final url = Uri.parse(contentState.url);
|
||||||
|
|
||||||
|
// Determine title based on priority: new non-empty title > existing title if URL unchanged > new title
|
||||||
|
final String resolvedTitle;
|
||||||
|
if (contentState.title.isNotEmpty) {
|
||||||
|
resolvedTitle = contentState.title;
|
||||||
|
} else if (current.url == url) {
|
||||||
|
resolvedTitle = current.title;
|
||||||
|
} else {
|
||||||
|
resolvedTitle = contentState.title;
|
||||||
|
}
|
||||||
|
|
||||||
final newState = current.copyWith(
|
final newState = current.copyWith(
|
||||||
parentId: contentState.parentId,
|
parentId: contentState.parentId,
|
||||||
contextId: contentState.contextId,
|
contextId: contentState.contextId,
|
||||||
url: Uri.parse(contentState.url),
|
url: url,
|
||||||
title: contentState.title,
|
title: resolvedTitle,
|
||||||
progress: contentState.progress,
|
progress: contentState.progress,
|
||||||
isPrivate: contentState.isPrivate,
|
isPrivate: contentState.isPrivate,
|
||||||
isFullScreen: contentState.isFullScreen,
|
isFullScreen: contentState.isFullScreen,
|
||||||
|
|||||||
Reference in New Issue
Block a user