clear data of isolated containers; improved tab handling/state/duplication;
This commit is contained in:
@@ -46,9 +46,9 @@ part 'tab_state.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class TabStates extends _$TabStates {
|
||||
void _onTabContentStateChange(TabContentState contentState) {
|
||||
final current =
|
||||
state[contentState.id] ?? TabState.$default(contentState.id);
|
||||
Future<void> _onTabContentStateChange(TabContentState contentState) async {
|
||||
final current = await patchedState(contentState.id);
|
||||
|
||||
final url = Uri.parse(contentState.url);
|
||||
|
||||
// Determine title based on priority: new non-empty title > existing title if URL authority unchanged > new title
|
||||
@@ -81,6 +81,27 @@ class TabStates extends _$TabStates {
|
||||
}
|
||||
}
|
||||
|
||||
Future<TabState> patchedState(String id) async {
|
||||
var current = stateOrNull?[id];
|
||||
|
||||
if (current == null || current.url == TabState.defaultUrl) {
|
||||
current ??= TabState.$default(id);
|
||||
|
||||
final tabData = await ref
|
||||
.read(tabDataRepositoryProvider.notifier)
|
||||
.getTabDataById(id);
|
||||
|
||||
if (tabData?.url != null) {
|
||||
current = current.copyWith(
|
||||
title: tabData!.title ?? current.title,
|
||||
url: tabData.url ?? current.url,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
Future<void> _onIconChange(IconChangeEvent event) async {
|
||||
final IconChangeEvent(:tabId, :bytes) = event;
|
||||
|
||||
@@ -174,8 +195,8 @@ class TabStates extends _$TabStates {
|
||||
final eventService = ref.watch(eventServiceProvider);
|
||||
|
||||
final subscriptions = [
|
||||
eventService.tabContentEvents.listen((event) {
|
||||
_onTabContentStateChange(event);
|
||||
eventService.tabContentEvents.listen((event) async {
|
||||
await _onTabContentStateChange(event);
|
||||
}),
|
||||
eventService.iconChangeEvents.listen((event) async {
|
||||
await _onIconChange(event);
|
||||
|
||||
@@ -41,7 +41,7 @@ final class TabStatesProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$tabStatesHash() => r'778242f0b67eb7646014d0df857a3a71de214c40';
|
||||
String _$tabStatesHash() => r'cd73ea6ea479f2708a2c9e5ca86054c9d2464116';
|
||||
|
||||
abstract class _$TabStates extends $Notifier<Map<String, TabState>> {
|
||||
Map<String, TabState> build();
|
||||
|
||||
Reference in New Issue
Block a user