cache
This commit is contained in:
@@ -230,10 +230,6 @@ extension StateControllerExt on AppController {
|
||||
return _ref.read(getSelectedProxyNameProvider(groupName));
|
||||
}
|
||||
|
||||
Future<SetupState> getSetupState(int profileId) async {
|
||||
return await _ref.read(setupStateProvider(profileId).future);
|
||||
}
|
||||
|
||||
String getRealTestUrl(String? url) {
|
||||
return _ref.read(realTestUrlProvider(url));
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ Map<String, dynamic> _$ProfileToJson(_Profile instance) => <String, dynamic>{
|
||||
const _$OverwriteTypeEnumMap = {
|
||||
OverwriteType.standard: 'standard',
|
||||
OverwriteType.script: 'script',
|
||||
OverwriteType.custom: 'custom',
|
||||
};
|
||||
|
||||
_StandardOverwrite _$StandardOverwriteFromJson(Map<String, dynamic> json) =>
|
||||
|
||||
@@ -60,7 +60,7 @@ class _EditorPageState extends ConsumerState<EditorPage> {
|
||||
super.initState();
|
||||
readOnly = widget.onSave == null;
|
||||
_toolbarController = ContextMenuControllerImpl(readOnly);
|
||||
_focusNode = FocusNode(canRequestFocus: !readOnly);
|
||||
_focusNode = FocusNode();
|
||||
_controller = CodeLineEditingController.fromText(widget.content);
|
||||
_findController = CodeFindController(_controller);
|
||||
_titleController = TextEditingController(text: widget.title);
|
||||
@@ -259,6 +259,7 @@ class _EditorPageState extends ConsumerState<EditorPage> {
|
||||
body: CodeEditor(
|
||||
readOnly: readOnly,
|
||||
autofocus: false,
|
||||
showCursorWhenReadOnly: false,
|
||||
findController: _findController,
|
||||
findBuilder: (context, controller, readOnly) => FindPanel(
|
||||
controller: controller,
|
||||
@@ -408,7 +409,7 @@ class FindPanel extends StatelessWidget implements PreferredSizeWidget {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [bar, SizedBox(height: 4), _buildFindInput(context, value)],
|
||||
children: [bar, SizedBox(height: 12), _buildFindInput(context, value)],
|
||||
);
|
||||
}
|
||||
return bar;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/database/database.dart';
|
||||
@@ -16,6 +18,11 @@ Stream<List<Rule>> addedRuleStream(Ref ref, int profileId) {
|
||||
return database.rulesDao.allAddedRules(profileId).watch();
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<List<Rule>> addedRules(Ref ref, int profileId) {
|
||||
return database.rulesDao.allAddedRules(profileId).get();
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class Profiles extends _$Profiles {
|
||||
@override
|
||||
|
||||
@@ -122,6 +122,80 @@ final class AddedRuleStreamFamily extends $Family
|
||||
String toString() => r'addedRuleStreamProvider';
|
||||
}
|
||||
|
||||
@ProviderFor(addedRules)
|
||||
const addedRulesProvider = AddedRulesFamily._();
|
||||
|
||||
final class AddedRulesProvider
|
||||
extends
|
||||
$FunctionalProvider<
|
||||
AsyncValue<List<Rule>>,
|
||||
List<Rule>,
|
||||
FutureOr<List<Rule>>
|
||||
>
|
||||
with $FutureModifier<List<Rule>>, $FutureProvider<List<Rule>> {
|
||||
const AddedRulesProvider._({
|
||||
required AddedRulesFamily super.from,
|
||||
required int super.argument,
|
||||
}) : super(
|
||||
retry: null,
|
||||
name: r'addedRulesProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$addedRulesHash();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return r'addedRulesProvider'
|
||||
''
|
||||
'($argument)';
|
||||
}
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$FutureProviderElement<List<Rule>> $createElement($ProviderPointer pointer) =>
|
||||
$FutureProviderElement(pointer);
|
||||
|
||||
@override
|
||||
FutureOr<List<Rule>> create(Ref ref) {
|
||||
final argument = this.argument as int;
|
||||
return addedRules(ref, argument);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is AddedRulesProvider && other.argument == argument;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return argument.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
String _$addedRulesHash() => r'fa2569f7781c93e00bd2017c956ff377e436667a';
|
||||
|
||||
final class AddedRulesFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<List<Rule>>, int> {
|
||||
const AddedRulesFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'addedRulesProvider',
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
isAutoDispose: true,
|
||||
);
|
||||
|
||||
AddedRulesProvider call(int profileId) =>
|
||||
AddedRulesProvider._(argument: profileId, from: this);
|
||||
|
||||
@override
|
||||
String toString() => r'addedRulesProvider';
|
||||
}
|
||||
|
||||
@ProviderFor(Profiles)
|
||||
const profilesProvider = ProfilesProvider._();
|
||||
|
||||
|
||||
@@ -2497,7 +2497,7 @@ final class SetupStateProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$setupStateHash() => r'8e0c849fa1a51ee15f8b40be94e3094182325b58';
|
||||
String _$setupStateHash() => r'afa3c071f19b9d5fc0e25c2098e001e4a2901c92';
|
||||
|
||||
final class SetupStateFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SetupState>, int?> {
|
||||
|
||||
@@ -686,9 +686,15 @@ Future<SetupState> setupState(Ref ref, int? profileId) async {
|
||||
final dns = ref.watch(patchClashConfigProvider.select((state) => state.dns));
|
||||
final script = await ref.watch(scriptProvider(scriptId).future);
|
||||
final overrideDns = ref.watch(overrideDnsProvider);
|
||||
final List<Rule> addedRules = profileId != null
|
||||
? await ref.watch(addedRuleStreamProvider(profileId).future)
|
||||
: [];
|
||||
List<Rule> addedRules = [];
|
||||
if (profileId != null) {
|
||||
final currentProfileId = ref.read(currentProfileIdProvider);
|
||||
if (currentProfileId == profileId) {
|
||||
addedRules = await ref.watch(addedRuleStreamProvider(profileId).future);
|
||||
} else {
|
||||
addedRules = await ref.read(addedRulesProvider(profileId).future);
|
||||
}
|
||||
}
|
||||
return SetupState(
|
||||
profileId: profileId,
|
||||
profileLastUpdateDate: profileLastUpdateDate,
|
||||
|
||||
@@ -34,7 +34,11 @@ class _ProfilesViewState extends State<ProfilesView> {
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
Scrollable.ensureVisible(context, duration: commonDuration);
|
||||
Scrollable.ensureVisible(
|
||||
context,
|
||||
duration: commonDuration,
|
||||
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user