Skip to content

Commit

Permalink
Try to fix not being able to open library after going back to New Tab
Browse files Browse the repository at this point in the history
  • Loading branch information
haanhvu committed Dec 2, 2024
1 parent 6e6592c commit 06a1cd7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ private void updateUI() {
v.requestFocusFromTouch();

if (mViewModel.getBackToNewTabEnabled().getValue().get()) {
mAttachedWindow.showNewTab();
//mAttachedWindow.showNewTab();
getSession().loadUri(UrlUtils.ABOUT_NEWTAB);
}

if (getSession().canGoBack()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ public void showPanel(Windows.ContentType panelType) {

private void showPanel(Windows.ContentType contentType, boolean switchSurface) {
if (mLibrary == null) {
Log.e("New Tab PR", "showPanel(): mLibrary is null");
return;
}

Expand All @@ -535,10 +536,12 @@ private void showPanel(Windows.ContentType contentType, boolean switchSurface) {
mViewModel.setCurrentContentType(contentType);
mViewModel.setUrl(contentType.URL);
if (mView == null) {
Log.e("New Tab PR", "mView == null");
setView(mLibrary, switchSurface);
mLibrary.selectPanel(contentType);
mLibrary.onShow();
if (mRestoreFirstPaint == null && !isFirstPaintReady() && (mFirstDrawCallback != null) && (mSurface != null)) {
Log.e("New Tab PR", "if clause is run");
final Runnable firstDrawCallback = mFirstDrawCallback;
onFirstContentfulPaint(mSession.getWSession());
mRestoreFirstPaint = () -> {
Expand All @@ -548,9 +551,14 @@ private void showPanel(Windows.ContentType contentType, boolean switchSurface) {
mWidgetManager.updateWidget(WindowWidget.this);
}
};
} else {
Log.e("New Tab PR", "if clause is NOT run");
}
} else if (mView == mLibrary) {
Log.e("New Tab PR", "mView == null");
mLibrary.selectPanel(contentType);
} else {
Log.e("New Tab PR", "Other case");
}
}

Expand Down Expand Up @@ -601,16 +609,23 @@ public void hideNewTab() {
if (mViewModel.getCurrentContentType().getValue() == Windows.ContentType.NEW_TAB) {
mViewModel.enableBackToNewTab(true);
hideNewTab(true);
} else {
Log.e("New Tab PR", "Current content type is not New Tab");
}
}

private void hideNewTab(boolean switchSurface) {
if (mView != null && mNewTab != null) {
unsetView(mNewTab, switchSurface);
} else {
Log.e("New Tab PR", "Cannot unset New Tab view");
}
if (switchSurface && mRestoreFirstPaint != null) {
Log.e("New Tab PR", "mRestoreFirstPaint is not null => Can make null");
mRestoreFirstPaint.run();
mRestoreFirstPaint = null;
} else {
Log.e("New Tab PR", "Cannot make mRestoreFirstPaint null");
}
}

Expand Down

0 comments on commit 06a1cd7

Please sign in to comment.