increase min sdk and apply new formatter
This commit is contained in:
@@ -24,12 +24,14 @@ class TabStates extends _$TabStates {
|
||||
void _onTabContentStateChange(TabContentState contentState) {
|
||||
final current =
|
||||
state[contentState.id] ?? TabState.$default(contentState.id);
|
||||
state = {...state}..[contentState.id] = current.copyWith(
|
||||
state = {...state}
|
||||
..[contentState.id] = current.copyWith(
|
||||
contextId: contentState.contextId,
|
||||
url: Uri.parse(contentState.url),
|
||||
title: (contentState.title.isNotEmpty)
|
||||
? contentState.title
|
||||
: current.title,
|
||||
title:
|
||||
(contentState.title.isNotEmpty)
|
||||
? contentState.title
|
||||
: current.title,
|
||||
progress: contentState.progress,
|
||||
isPrivate: contentState.isPrivate,
|
||||
isFullScreen: contentState.isFullScreen,
|
||||
@@ -65,7 +67,8 @@ class TabStates extends _$TabStates {
|
||||
final SecurityInfoEvent(:tabId, :securityInfo) = event;
|
||||
|
||||
final current = state[tabId] ?? TabState.$default(tabId);
|
||||
state = {...state}..[tabId] = current.copyWith.securityInfoState(
|
||||
state = {...state}
|
||||
..[tabId] = current.copyWith.securityInfoState(
|
||||
SecurityState(
|
||||
secure: securityInfo.secure,
|
||||
host: securityInfo.host,
|
||||
@@ -78,14 +81,18 @@ class TabStates extends _$TabStates {
|
||||
final HistoryEvent(:tabId, :history) = event;
|
||||
|
||||
final current = state[tabId] ?? TabState.$default(tabId);
|
||||
state = {...state}..[tabId] = current.copyWith.historyState(
|
||||
state = {...state}
|
||||
..[tabId] = current.copyWith.historyState(
|
||||
HistoryState(
|
||||
items: history.items.nonNulls
|
||||
.map(
|
||||
(item) =>
|
||||
HistoryItem(url: Uri.parse(item.url), title: item.title),
|
||||
)
|
||||
.toList(),
|
||||
items:
|
||||
history.items.nonNulls
|
||||
.map(
|
||||
(item) => HistoryItem(
|
||||
url: Uri.parse(item.url),
|
||||
title: item.title,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
currentIndex: history.currentIndex,
|
||||
canGoBack: history.canGoBack,
|
||||
canGoForward: history.canGoForward,
|
||||
@@ -97,7 +104,8 @@ class TabStates extends _$TabStates {
|
||||
final ReaderableEvent(:tabId, :readerable) = event;
|
||||
|
||||
final current = state[tabId] ?? TabState.$default(tabId);
|
||||
state = {...state}..[tabId] = current.copyWith.readerableState(
|
||||
state = {...state}
|
||||
..[tabId] = current.copyWith.readerableState(
|
||||
ReaderableState(
|
||||
readerable: readerable.readerable,
|
||||
active: readerable.active,
|
||||
@@ -112,7 +120,8 @@ class TabStates extends _$TabStates {
|
||||
final result = results.last;
|
||||
|
||||
final current = state[tabId] ?? TabState.$default(tabId);
|
||||
state = {...state}..[tabId] = current.copyWith.findResultState(
|
||||
state = {...state}
|
||||
..[tabId] = current.copyWith.findResultState(
|
||||
FindResultState(
|
||||
activeMatchOrdinal: result.activeMatchOrdinal,
|
||||
numberOfMatches: result.numberOfMatches,
|
||||
@@ -127,59 +136,44 @@ class TabStates extends _$TabStates {
|
||||
final eventService = ref.watch(eventServiceProvider);
|
||||
|
||||
final subscriptions = [
|
||||
eventService.tabContentEvents.listen(
|
||||
(event) async {
|
||||
await _lock.synchronized(() => _onTabContentStateChange(event));
|
||||
},
|
||||
),
|
||||
eventService.iconChangeEvents.listen(
|
||||
(event) async {
|
||||
await _lock.synchronized(() => _onIconChange(event));
|
||||
},
|
||||
),
|
||||
eventService.thumbnailEvents.listen(
|
||||
(event) async {
|
||||
await _lock.synchronized(() => _onThumbnailChange(event));
|
||||
},
|
||||
),
|
||||
eventService.securityInfoEvents.listen(
|
||||
(event) async {
|
||||
await _lock.synchronized(() => _onSecurityInfoStateChange(event));
|
||||
},
|
||||
),
|
||||
eventService.historyEvents.listen(
|
||||
(event) async {
|
||||
await _lock.synchronized(() => _onHistoryStateChange(event));
|
||||
},
|
||||
),
|
||||
eventService.readerableEvents.listen(
|
||||
(event) async {
|
||||
await _lock.synchronized(() => _onReaderableStateChange(event));
|
||||
},
|
||||
),
|
||||
eventService.findResultsEvent.listen(
|
||||
(event) async {
|
||||
await _lock.synchronized(() => _onFindResultsChange(event));
|
||||
},
|
||||
),
|
||||
eventService.tabContentEvents.listen((event) async {
|
||||
await _lock.synchronized(() => _onTabContentStateChange(event));
|
||||
}),
|
||||
eventService.iconChangeEvents.listen((event) async {
|
||||
await _lock.synchronized(() => _onIconChange(event));
|
||||
}),
|
||||
eventService.thumbnailEvents.listen((event) async {
|
||||
await _lock.synchronized(() => _onThumbnailChange(event));
|
||||
}),
|
||||
eventService.securityInfoEvents.listen((event) async {
|
||||
await _lock.synchronized(() => _onSecurityInfoStateChange(event));
|
||||
}),
|
||||
eventService.historyEvents.listen((event) async {
|
||||
await _lock.synchronized(() => _onHistoryStateChange(event));
|
||||
}),
|
||||
eventService.readerableEvents.listen((event) async {
|
||||
await _lock.synchronized(() => _onReaderableStateChange(event));
|
||||
}),
|
||||
eventService.findResultsEvent.listen((event) async {
|
||||
await _lock.synchronized(() => _onFindResultsChange(event));
|
||||
}),
|
||||
];
|
||||
|
||||
ref.listen(
|
||||
fireImmediately: true,
|
||||
engineReadyStateProvider,
|
||||
(previous, next) async {
|
||||
if (next) {
|
||||
await GeckoTabService().syncEvents(
|
||||
onTabContentStateChange: true,
|
||||
onIconChange: true,
|
||||
onThumbnailChange: true,
|
||||
onSecurityInfoStateChange: true,
|
||||
onHistoryStateChange: true,
|
||||
onFindResults: true,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
ref.listen(fireImmediately: true, engineReadyStateProvider, (
|
||||
previous,
|
||||
next,
|
||||
) async {
|
||||
if (next) {
|
||||
await GeckoTabService().syncEvents(
|
||||
onTabContentStateChange: true,
|
||||
onIconChange: true,
|
||||
onThumbnailChange: true,
|
||||
onSecurityInfoStateChange: true,
|
||||
onHistoryStateChange: true,
|
||||
onFindResults: true,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
ref.onDispose(() {
|
||||
for (final sub in subscriptions) {
|
||||
@@ -197,9 +191,7 @@ TabState? tabState(Ref ref, String? tabId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ref.watch(
|
||||
tabStatesProvider.select((tabs) => tabs[tabId]),
|
||||
);
|
||||
return ref.watch(tabStatesProvider.select((tabs) => tabs[tabId]));
|
||||
}
|
||||
|
||||
@Riverpod()
|
||||
|
||||
Reference in New Issue
Block a user