Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/core/messages/pdf_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ abstract class PdfMessages {
static const String directLinkUnavailableForBook =
'קישור ישיר אינו זמין לספר זה';
static const String perBookSettingsReset = 'ההגדרות האישיות לספר זה אופסו';
static const String textLocationNotFoundOpeningAtStart =
'לא נמצא מיקום תואם בטקסט — הספר נפתח מתחילתו';
static const String textLocationNotFound = 'לא נמצא מיקום תואם בטקסט';
static const String noTextLayer =
'ספר זה הוא סריקה בלבד ואינו מכיל טקסט, ולכן לא ניתן לחפש בתוכו';
static const String advancedSearchUnavailableInTalmudPdf =
Expand Down
3 changes: 1 addition & 2 deletions lib/core/messages/text_book_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ abstract class TextBookMessages {
static String pdfNotFoundForBook(String bookTitle) =>
'לא נמצא ספר PDF עבור "$bookTitle"';

static const String pdfLocationNotFoundOpeningAtStart =
'לא נמצא מיקום תואם ב-PDF — הספר נפתח מתחילתו';
static const String pdfLocationNotFound = 'לא נמצא מיקום תואם ב-PDF';

static const String pairedBookLocationNotFound =
'לא נמצא סימן תואם בספר המקביל';
Expand Down
10 changes: 7 additions & 3 deletions lib/pdf_book/view/pdf_book_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,7 @@ class _PdfBookScreenState extends State<PdfBookScreen>
otz_links.Link link,
) async {
final textBook = TextBook(
id: link.targetBookId,
title: utils.getTitleFromPath(link.path2),
source: link.targetSource,
categoryId: link.targetCategoryId,
Expand All @@ -1232,6 +1233,7 @@ class _PdfBookScreenState extends State<PdfBookScreen>
ignoreHistory: true,
requiresStableLayout: true,
insertAdjacent: true,
navigateToPositionIfReused: true,
);
return;
}
Expand All @@ -1240,8 +1242,9 @@ class _PdfBookScreenState extends State<PdfBookScreen>
textBook,
textIndex,
'',
ignoreHistory: false,
explicitIndex: true,
insertAdjacent: true,
navigateToPositionIfReused: true,
);
}

Expand Down Expand Up @@ -5750,15 +5753,16 @@ class _PdfBookScreenState extends State<PdfBookScreen>
if (!context.mounted) return;

if (index == null) {
UiSnack.show(PdfMessages.textLocationNotFoundOpeningAtStart);
UiSnack.show(PdfMessages.textLocationNotFound);
}
openBook(
context,
textBook,
index ?? 0,
index,
'',
ignoreHistory: true,
insertAdjacent: true,
navigateToPositionIfReused: true,
);
}

Expand Down
23 changes: 12 additions & 11 deletions lib/tabs/bloc/tabs_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,16 @@ class TabsBloc extends Bloc<TabsEvent, TabsState> {
);
return;
}
// הכותרת משמשת רק להשוואה מול חלונית של אותו ספר; בלעדיה נחסכת טעינת
// תוכן העניינים לפני הוספת הטאב, והקורא טוען אותו ממילא.
final hasSameBook = state.tabs
.expand(leafPanes)
.any((open) => _isSameBook(open, event.tab));
final targetTitle =
hasSameBook &&
(!event.matchHistorySlot || event.tab.historySlot == null)
final ignoreLocation =
event.matchBookOnly || event.navigateToPositionIfReused;
// צריך כותרת (ולפעמים TOC) רק כשמשווים מיקומים באותו ספר.
final needsTitle =
!ignoreLocation &&
(!event.matchHistorySlot || event.tab.historySlot == null) &&
state.tabs
.expand(leafPanes)
.any((open) => _isSameBook(open, event.tab));
final targetTitle = needsTitle
? await _resolveTabLocationTitle(
event.tab,
explicitTitle: event.targetTitle,
Expand All @@ -608,8 +610,7 @@ class TabsBloc extends Bloc<TabsEvent, TabsState> {
final matchingIndex = await _findMatchingTopLevelTabIndex(
event.tab,
targetTitle,
// סימניה או deep link מנווטים בספר הפתוח גם כשהכותרת המבוקשת שונה.
ignoreLocation: event.navigateToPositionIfReused,
ignoreLocation: ignoreLocation,
matchHistorySlot: event.matchHistorySlot,
);

Expand All @@ -618,7 +619,7 @@ class TabsBloc extends Bloc<TabsEvent, TabsState> {
state.tabs[matchingIndex],
event.tab,
targetTitle,
ignoreLocation: event.navigateToPositionIfReused,
ignoreLocation: ignoreLocation,
matchHistorySlot: event.matchHistorySlot,
);
final matchingTab = matchingPane ?? state.tabs[matchingIndex];
Expand Down
5 changes: 5 additions & 0 deletions lib/tabs/bloc/tabs_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class OpenOrFocusTab extends TabsEvent {
/// מנווט את הטאב הממוחזר למיקום הנכנס כשנבחר יעד מפורש בסימניה או קישור.
final bool navigateToPositionIfReused;

/// מאפשר למקד לפי זהות הספר גם כשאין יעד גלילה ידוע.
final bool matchBookOnly;

/// פתיחה ברקע: תמיד טאב חדש (בלי מיקוד טאב קיים), והמשתמש נשאר על הנוכחי.
final bool inBackground;

Expand All @@ -54,6 +57,7 @@ class OpenOrFocusTab extends TabsEvent {
this.targetTitle,
this.insertAdjacent = false,
this.navigateToPositionIfReused = false,
this.matchBookOnly = false,
this.matchHistorySlot = false,
this.inBackground = false,
});
Expand All @@ -64,6 +68,7 @@ class OpenOrFocusTab extends TabsEvent {
targetTitle,
insertAdjacent,
navigateToPositionIfReused,
matchBookOnly,
matchHistorySlot,
inBackground,
];
Expand Down
11 changes: 7 additions & 4 deletions lib/text_book/view/text_book_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2225,6 +2225,7 @@ class _TextBookViewerBlocState extends State<TextBookViewerBloc>
ignoreHistory: true,
requiresStableLayout: true,
insertAdjacent: true,
navigateToPositionIfReused: true,
);
}

Expand Down Expand Up @@ -2279,16 +2280,17 @@ class _TextBookViewerBlocState extends State<TextBookViewerBloc>
if (!context.mounted) return;

if (index == null) {
UiSnack.show(TextBookMessages.pdfLocationNotFoundOpeningAtStart);
UiSnack.show(TextBookMessages.pdfLocationNotFound);
}
openBook(
context,
_pdfBook!,
index ?? 1,
index,
'',
ignoreHistory: true,
requiresStableLayout: true,
insertAdjacent: true,
navigateToPositionIfReused: true,
);
}

Expand Down Expand Up @@ -3224,16 +3226,17 @@ void _togglePdfView(
if (!context.mounted) return;

if (index == null) {
UiSnack.show(TextBookMessages.pdfLocationNotFoundOpeningAtStart);
UiSnack.show(TextBookMessages.pdfLocationNotFound);
}
openBook(
context,
book,
index ?? 1,
index,
'',
ignoreHistory: true,
requiresStableLayout: true,
insertAdjacent: true,
navigateToPositionIfReused: true,
);
}

Expand Down
10 changes: 7 additions & 3 deletions lib/utils/navigation/book_open_coordinator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class BookOpenCoordinator {
this.layoutWidth,
});

/// מיקום חסר משאיר את הטאב הפתוח במקומו, או פותח עם מיקום ברירת המחדל.
void openBook(
Book book,
int index,
int? index,
String searchQuery, {
bool ignoreHistory = false,
bool explicitIndex = false,
Expand All @@ -52,7 +53,7 @@ class BookOpenCoordinator {
}) {
final tab = buildTab(
book,
index,
index ?? (book is PdfBook ? 1 : 0),
searchQuery,
ignoreHistory: ignoreHistory,
explicitIndex: explicitIndex,
Expand All @@ -67,7 +68,8 @@ class BookOpenCoordinator {
openTab(
tab,
insertAdjacent: insertAdjacent,
navigateToPositionIfReused: navigateToPositionIfReused,
navigateToPositionIfReused: index != null && navigateToPositionIfReused,
matchBookOnly: index == null,
inSidePane: inSidePane,
navigate: navigate,
captureHistory: captureHistory,
Expand All @@ -84,6 +86,7 @@ class BookOpenCoordinator {
OpenedTab tab, {
bool insertAdjacent = false,
bool navigateToPositionIfReused = false,
bool matchBookOnly = false,
bool inSidePane = false,
bool navigate = true,
bool captureHistory = true,
Expand All @@ -105,6 +108,7 @@ class BookOpenCoordinator {
tab,
insertAdjacent: insertAdjacent,
navigateToPositionIfReused: navigateToPositionIfReused,
matchBookOnly: matchBookOnly,
),
);
if (navigate) showReadingScreen();
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/navigation/open_book.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ BookOpenCoordinator bookOpenCoordinatorOf(BuildContext context) =>
layoutWidth: readingLayoutWidthResolverOf(context),
);

/// מיקום חסר שומר על מקום הקריאה אם הספר כבר פתוח.
void openBook(
BuildContext context,
Book book,
int index,
int? index,
String searchQuery, {
bool ignoreHistory = false,
bool explicitIndex = false,
Expand Down
1 change: 1 addition & 0 deletions test/plugins/bridge/plugin_bridge_adapter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class _RecordingReaderCoordinator extends BookOpenCoordinator {
OpenedTab tab, {
bool insertAdjacent = false,
bool navigateToPositionIfReused = false,
bool matchBookOnly = false,
bool inSidePane = false,
bool navigate = true,
bool captureHistory = true,
Expand Down
Loading
Loading