mirror of
https://github.com/Livinglist/Hacki.git
synced 2025-08-06 18:24:42 +08:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
ed48d95375 |
@ -9,6 +9,7 @@ import 'package:hacki/config/locator.dart';
|
||||
import 'package:hacki/cubits/cubits.dart';
|
||||
import 'package:hacki/models/models.dart';
|
||||
import 'package:hacki/repositories/repositories.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
|
||||
part 'notification_state.dart';
|
||||
|
||||
@ -19,6 +20,7 @@ class NotificationCubit extends Cubit<NotificationState> {
|
||||
HackerNewsRepository? hackerNewsRepository,
|
||||
PreferenceRepository? preferenceRepository,
|
||||
SembastRepository? sembastRepository,
|
||||
Logger? logger,
|
||||
}) : _authBloc = authBloc,
|
||||
_preferenceCubit = preferenceCubit,
|
||||
_hackerNewsRepository =
|
||||
@ -27,6 +29,7 @@ class NotificationCubit extends Cubit<NotificationState> {
|
||||
preferenceRepository ?? locator.get<PreferenceRepository>(),
|
||||
_sembastRepository =
|
||||
sembastRepository ?? locator.get<SembastRepository>(),
|
||||
_logger = logger ?? locator.get<Logger>(),
|
||||
super(NotificationState.init()) {
|
||||
_authBloc.stream
|
||||
.map((AuthState event) => event.username)
|
||||
@ -58,6 +61,7 @@ class NotificationCubit extends Cubit<NotificationState> {
|
||||
final HackerNewsRepository _hackerNewsRepository;
|
||||
final PreferenceRepository _preferenceRepository;
|
||||
final SembastRepository _sembastRepository;
|
||||
final Logger _logger;
|
||||
Timer? _timer;
|
||||
|
||||
static const Duration _refreshInterval = Duration(minutes: 5);
|
||||
@ -74,6 +78,7 @@ class NotificationCubit extends Cubit<NotificationState> {
|
||||
});
|
||||
|
||||
await _preferenceRepository.unreadCommentsIds.then((List<int> unreadIds) {
|
||||
_logger.i('NotificationCubit: ${unreadIds.length} unread items.');
|
||||
emit(state.copyWith(unreadCommentsIds: unreadIds));
|
||||
});
|
||||
|
||||
|
@ -186,7 +186,7 @@ class AutoScrollModePreference extends BooleanPreference {
|
||||
String get key => 'autoScrollMode';
|
||||
|
||||
@override
|
||||
String get title => 'Auto-scroll on collapsing';
|
||||
String get title => 'Auto-scroll on Collapsing';
|
||||
|
||||
@override
|
||||
String get subtitle =>
|
||||
|
@ -97,7 +97,7 @@ class HackerNewsWebRepository {
|
||||
|
||||
static const String _itemBaseUrl = 'https://news.ycombinator.com/item?id=';
|
||||
static const String _athingComtrSelector =
|
||||
'#hnmain > tbody > tr:nth-child(3) > td > table > tbody > .athing.comtr';
|
||||
'#hnmain > tbody > tr > td > table > tbody > .athing.comtr';
|
||||
static const String _commentTextSelector =
|
||||
'''td > table > tbody > tr > td.default > div.comment''';
|
||||
static const String _commentHeadSelector =
|
||||
@ -153,6 +153,10 @@ class HackerNewsWebRepository {
|
||||
Iterable<Element> elements = await fetchElements(page);
|
||||
final Map<int, int> indentToParentId = <int, int>{};
|
||||
|
||||
if (item is Story && item.descendants > 0 && elements.isEmpty) {
|
||||
throw PossibleParsingException(itemId: itemId);
|
||||
}
|
||||
|
||||
while (elements.isNotEmpty) {
|
||||
for (final Element element in elements) {
|
||||
/// Get comment id.
|
||||
|
@ -49,7 +49,7 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
super.didPopNext();
|
||||
if (context.read<StoriesBloc>().deviceScreenType ==
|
||||
DeviceScreenType.mobile) {
|
||||
locator.get<Logger>().i('Resetting comments in CommentCache');
|
||||
locator.get<Logger>().i('resetting comments in CommentCache');
|
||||
Future<void>.delayed(
|
||||
AppDurations.ms500,
|
||||
locator.get<CommentCache>().resetComments,
|
||||
|
@ -120,7 +120,7 @@ class WebAnalyzer {
|
||||
|
||||
if (info != null) {
|
||||
locator.get<Logger>().d('''
|
||||
Fetched mem cached metadata using key $key for $story:
|
||||
fetched mem cached metadata using key $key for $story:
|
||||
${info.toJson()}
|
||||
''');
|
||||
return info;
|
||||
@ -168,7 +168,7 @@ ${info.toJson()}
|
||||
/// [5] If there is file cache, move it to mem cache for later retrieval.
|
||||
if (info != null) {
|
||||
locator.get<Logger>().d('''
|
||||
Fetched file cached metadata using key $key for $story:
|
||||
fetched file cached metadata using key $key for $story:
|
||||
${info.toJson()}
|
||||
''');
|
||||
cacheMap[key] = info;
|
||||
@ -189,7 +189,7 @@ ${info.toJson()}
|
||||
if (info is WebInfo) {
|
||||
locator
|
||||
.get<Logger>()
|
||||
.d('Caching metadata using key $key for $story.');
|
||||
.d('caching metadata using key $key for $story.');
|
||||
unawaited(
|
||||
locator.get<SembastRepository>().cacheMetadata(
|
||||
key: key,
|
||||
@ -422,7 +422,7 @@ ${info.toJson()}
|
||||
} catch (e) {
|
||||
locator
|
||||
.get<Logger>()
|
||||
.e('''Web page resolution failure from:$url Error:$e''');
|
||||
.e('''web page resolution failure from:$url Error:$e''');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1454,4 +1454,4 @@ packages:
|
||||
version: "3.1.2"
|
||||
sdks:
|
||||
dart: ">=3.2.0-194.0.dev <4.0.0"
|
||||
flutter: ">=3.16.3"
|
||||
flutter: ">=3.16.5"
|
||||
|
@ -1,11 +1,11 @@
|
||||
name: hacki
|
||||
description: A Hacker News reader.
|
||||
version: 2.6.1+136
|
||||
version: 2.6.2+137
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
flutter: "3.16.3"
|
||||
flutter: "3.16.5"
|
||||
|
||||
dependencies:
|
||||
adaptive_theme: ^3.2.0
|
||||
|
Submodule submodules/flutter updated: b0366e0a3f...78666c8dc5
Reference in New Issue
Block a user