provider mounted hardenings
This commit is contained in:
@@ -55,6 +55,7 @@ class BottomSheetExtend extends _$BottomSheetExtend {
|
||||
@override
|
||||
Stream<double> build() {
|
||||
_extentStreamController = StreamController();
|
||||
|
||||
ref.onDispose(() async {
|
||||
await _extentStreamController.close();
|
||||
});
|
||||
|
||||
@@ -42,51 +42,59 @@ GeckoSelectionActionService selectionActionService(Ref ref) {
|
||||
unawaited(
|
||||
service.setActions([
|
||||
NewTabAction((text) async {
|
||||
final router = await ref.read(routerProvider.future);
|
||||
final settings = ref.read(generalSettingsWithDefaultsProvider);
|
||||
final route = SearchRoute(
|
||||
tabType:
|
||||
// ignore: only_use_keep_alive_inside_keep_alive
|
||||
ref.read(selectedTabTypeProvider) ??
|
||||
settings.defaultCreateTabType,
|
||||
searchText: text,
|
||||
);
|
||||
if (ref.mounted) {
|
||||
final router = await ref.read(routerProvider.future);
|
||||
if (ref.mounted) {
|
||||
final settings = ref.read(generalSettingsWithDefaultsProvider);
|
||||
final route = SearchRoute(
|
||||
tabType:
|
||||
// ignore: only_use_keep_alive_inside_keep_alive
|
||||
ref.read(selectedTabTypeProvider) ??
|
||||
settings.defaultCreateTabType,
|
||||
searchText: text,
|
||||
);
|
||||
|
||||
await router.push(route.location);
|
||||
await router.push(route.location);
|
||||
}
|
||||
}
|
||||
}),
|
||||
DefaultSearchAction((text) async {
|
||||
final defaultSearchBang = await ref.read(
|
||||
defaultSearchBangDataProvider.future,
|
||||
);
|
||||
if (ref.mounted) {
|
||||
final defaultSearchBang = await ref.read(
|
||||
defaultSearchBangDataProvider.future,
|
||||
);
|
||||
|
||||
if (defaultSearchBang != null) {
|
||||
// ignore: only_use_keep_alive_inside_keep_alive
|
||||
final currentTab = ref.read(selectedTabStateProvider);
|
||||
final isPrivate =
|
||||
currentTab?.isPrivate ??
|
||||
ref
|
||||
.read(generalSettingsWithDefaultsProvider)
|
||||
.defaultCreateTabType ==
|
||||
TabType.private;
|
||||
if (ref.mounted && defaultSearchBang != null) {
|
||||
// ignore: only_use_keep_alive_inside_keep_alive
|
||||
final currentTab = ref.read(selectedTabStateProvider);
|
||||
final isPrivate =
|
||||
currentTab?.isPrivate ??
|
||||
ref
|
||||
.read(generalSettingsWithDefaultsProvider)
|
||||
.defaultCreateTabType ==
|
||||
TabType.private;
|
||||
|
||||
await ref
|
||||
.read(tabRepositoryProvider.notifier)
|
||||
.addTab(
|
||||
url: defaultSearchBang.getTemplateUrl(text),
|
||||
parentId: currentTab?.id,
|
||||
private: isPrivate,
|
||||
);
|
||||
} else {
|
||||
logger.e('No default search bang found');
|
||||
await ref
|
||||
.read(tabRepositoryProvider.notifier)
|
||||
.addTab(
|
||||
url: defaultSearchBang.getTemplateUrl(text),
|
||||
parentId: currentTab?.id,
|
||||
private: isPrivate,
|
||||
);
|
||||
} else {
|
||||
logger.e('No default search bang found');
|
||||
}
|
||||
}
|
||||
}),
|
||||
FindInPageAction((text) async {
|
||||
final tabId = ref.read(selectedTabProvider);
|
||||
if (tabId != null) {
|
||||
// ignore: only_use_keep_alive_inside_keep_alive
|
||||
await ref
|
||||
.read(findInPageControllerProvider(tabId).notifier)
|
||||
.findAll(text: text);
|
||||
if (ref.mounted) {
|
||||
final tabId = ref.read(selectedTabProvider);
|
||||
if (tabId != null) {
|
||||
// ignore: only_use_keep_alive_inside_keep_alive
|
||||
await ref
|
||||
.read(findInPageControllerProvider(tabId).notifier)
|
||||
.findAll(text: text);
|
||||
}
|
||||
}
|
||||
}),
|
||||
ShareAction((text) async {
|
||||
|
||||
@@ -55,7 +55,7 @@ final class SelectionActionServiceProvider
|
||||
}
|
||||
|
||||
String _$selectionActionServiceHash() =>
|
||||
r'c89d981c2ba253ed940887fa59c11ad93d8589a8';
|
||||
r'424c2c444524ee4bf2302405cac3358c148a7b16';
|
||||
|
||||
@ProviderFor(eventService)
|
||||
const eventServiceProvider = EventServiceProvider._();
|
||||
|
||||
@@ -66,6 +66,8 @@ class TabRepository extends _$TabRepository {
|
||||
Value<ContainerData?>? container,
|
||||
bool launchedFromIntent = false,
|
||||
}) async {
|
||||
final tabDao = ref.read(tabDatabaseProvider).tabDao;
|
||||
|
||||
final assingedContainer =
|
||||
container ??
|
||||
Value<ContainerData?>(
|
||||
@@ -73,27 +75,24 @@ class TabRepository extends _$TabRepository {
|
||||
await ref.read(selectedContainerProvider.notifier).fetchData(),
|
||||
);
|
||||
|
||||
final newTabId = await ref
|
||||
.read(tabDatabaseProvider)
|
||||
.tabDao
|
||||
.upsertContainerTabTransactional(
|
||||
() {
|
||||
return _tabsService.addTab(
|
||||
url: url,
|
||||
selectTab: selectTab,
|
||||
startLoading: startLoading,
|
||||
parentId: parentId,
|
||||
flags: flags,
|
||||
contextId: assingedContainer.value?.metadata.contextualIdentity,
|
||||
source: source,
|
||||
private: private,
|
||||
historyMetadata: historyMetadata,
|
||||
additionalHeaders: additionalHeaders,
|
||||
);
|
||||
},
|
||||
parentId: Value(parentId),
|
||||
containerId: Value(assingedContainer.value?.id),
|
||||
final newTabId = await tabDao.upsertContainerTabTransactional(
|
||||
() {
|
||||
return _tabsService.addTab(
|
||||
url: url,
|
||||
selectTab: selectTab,
|
||||
startLoading: startLoading,
|
||||
parentId: parentId,
|
||||
flags: flags,
|
||||
contextId: assingedContainer.value?.metadata.contextualIdentity,
|
||||
source: source,
|
||||
private: private,
|
||||
historyMetadata: historyMetadata,
|
||||
additionalHeaders: additionalHeaders,
|
||||
);
|
||||
},
|
||||
parentId: Value(parentId),
|
||||
containerId: Value(assingedContainer.value?.id),
|
||||
);
|
||||
|
||||
if (launchedFromIntent) {
|
||||
_tabFromIntent.add(newTabId);
|
||||
@@ -107,26 +106,25 @@ class TabRepository extends _$TabRepository {
|
||||
String? containerId,
|
||||
bool selectTab = true,
|
||||
}) async {
|
||||
final tabDao = ref.read(tabDatabaseProvider).tabDao;
|
||||
|
||||
final containerData = await containerId.mapNotNull(
|
||||
(containerId) => ref
|
||||
.read(containerRepositoryProvider.notifier)
|
||||
.getContainerData(containerId),
|
||||
);
|
||||
|
||||
return ref
|
||||
.read(tabDatabaseProvider)
|
||||
.tabDao
|
||||
.upsertContainerTabTransactional(
|
||||
() {
|
||||
return _tabsService.duplicateTab(
|
||||
selectTabId: selectTabId,
|
||||
newContextId: containerData?.metadata.contextualIdentity,
|
||||
selectNewTab: selectTab,
|
||||
);
|
||||
},
|
||||
parentId: const Value.absent(),
|
||||
containerId: Value(containerData?.id),
|
||||
return await tabDao.upsertContainerTabTransactional(
|
||||
() {
|
||||
return _tabsService.duplicateTab(
|
||||
selectTabId: selectTabId,
|
||||
newContextId: containerData?.metadata.contextualIdentity,
|
||||
selectNewTab: selectTab,
|
||||
);
|
||||
},
|
||||
parentId: const Value.absent(),
|
||||
containerId: Value(containerData?.id),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> selectPreviouslyOpenedTab(String tabId) async {
|
||||
@@ -136,7 +134,7 @@ class TabRepository extends _$TabRepository {
|
||||
.previousTabByTimestamp(tabId: tabId)
|
||||
.getSingleOrNull();
|
||||
|
||||
if (previousTabId != null) {
|
||||
if (ref.mounted && previousTabId != null) {
|
||||
return selectTab(previousTabId);
|
||||
}
|
||||
|
||||
@@ -158,7 +156,7 @@ class TabRepository extends _$TabRepository {
|
||||
)
|
||||
.getSingleOrNull();
|
||||
|
||||
if (previousTabId != null) {
|
||||
if (ref.mounted && previousTabId != null) {
|
||||
return selectTab(previousTabId);
|
||||
}
|
||||
|
||||
@@ -180,7 +178,7 @@ class TabRepository extends _$TabRepository {
|
||||
)
|
||||
.getSingleOrNull();
|
||||
|
||||
if (previousTabId != null) {
|
||||
if (ref.mounted && previousTabId != null) {
|
||||
return selectTab(previousTabId);
|
||||
}
|
||||
|
||||
@@ -192,12 +190,16 @@ class TabRepository extends _$TabRepository {
|
||||
.read(tabDataRepositoryProvider.notifier)
|
||||
.getContainerTabId(tabId);
|
||||
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
final containerData = await containerId.mapNotNull(
|
||||
(containerId) => ref
|
||||
.read(containerRepositoryProvider.notifier)
|
||||
.getContainerData(containerId),
|
||||
);
|
||||
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
if (containerData != null) {
|
||||
if (containerData.metadata.authSettings.authenticationRequired) {
|
||||
// ignore: only_use_keep_alive_inside_keep_alive
|
||||
@@ -234,11 +236,15 @@ class TabRepository extends _$TabRepository {
|
||||
.read(tabDataRepositoryProvider.notifier)
|
||||
.getContainerTabId(tabId);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final sameContainerTabs = await ref
|
||||
.read(containerRepositoryProvider.notifier)
|
||||
.getContainerTabIds(currentContainerId)
|
||||
.then((tabs) => tabs.where((tab) => tab != tabId).toList());
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final previousTabId = await ref
|
||||
.read(tabDatabaseProvider)
|
||||
.definitionsDrift
|
||||
@@ -257,6 +263,8 @@ class TabRepository extends _$TabRepository {
|
||||
}
|
||||
}
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final previousOrderedTabId = await ref
|
||||
.read(tabDatabaseProvider)
|
||||
.definitionsDrift
|
||||
@@ -271,6 +279,8 @@ class TabRepository extends _$TabRepository {
|
||||
return _tabsService.selectTab(tabId: previousOrderedTabId);
|
||||
}
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final nextOrderedTabId = await ref
|
||||
.read(tabDatabaseProvider)
|
||||
.definitionsDrift
|
||||
@@ -285,6 +295,8 @@ class TabRepository extends _$TabRepository {
|
||||
return _tabsService.selectTab(tabId: nextOrderedTabId);
|
||||
}
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final unassignedTabs = await ref
|
||||
.read(containerRepositoryProvider.notifier)
|
||||
.getContainerTabIds(null)
|
||||
@@ -294,6 +306,8 @@ class TabRepository extends _$TabRepository {
|
||||
return _tabsService.selectTab(tabId: unassignedTabs.first);
|
||||
}
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
//We only take containers without authentication!
|
||||
final availableContainers = await ref
|
||||
.read(containerRepositoryProvider.notifier)
|
||||
@@ -305,6 +319,8 @@ class TabRepository extends _$TabRepository {
|
||||
container.metadata.authSettings.authenticationRequired == false,
|
||||
);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final nextContainerTabs = await nextAvailableContainerUnauthenticated
|
||||
.mapNotNull(
|
||||
(container) => ref
|
||||
@@ -317,7 +333,7 @@ class TabRepository extends _$TabRepository {
|
||||
return _tabsService.selectTab(tabId: nextContainerTabs!.first);
|
||||
}
|
||||
|
||||
if (availableContainers.isNotEmpty) {
|
||||
if (ref.mounted && availableContainers.isNotEmpty) {
|
||||
//Last resort push new tab to avoid any authenticated tab is selected
|
||||
// ignore: avoid_redundant_argument_values
|
||||
await addTab(selectTab: true, private: false);
|
||||
|
||||
@@ -41,7 +41,7 @@ final class TabRepositoryProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$tabRepositoryHash() => r'adf53bb00e5c80e9fcad6b9111d5723c996e966f';
|
||||
String _$tabRepositoryHash() => r'6fd5f78d5e5b728984b10a8824e06e82c5c26f4c';
|
||||
|
||||
abstract class _$TabRepository extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
Reference in New Issue
Block a user