diff --git a/android/app/src/main/assets/js/polyfill-onscrollend.js b/android/app/src/main/assets/js/polyfill-onscrollend.js new file mode 100644 index 0000000000..0382a0c160 --- /dev/null +++ b/android/app/src/main/assets/js/polyfill-onscrollend.js @@ -0,0 +1,91 @@ +/* eslint-disable eslint-comments/no-unlimited-disable */ +/* eslint-disable */ +'use strict'; +(() => { + function f(i, o, r, s = !1) { + if (!(o in i) || typeof r != 'function') return !1; + let t = i[o]; + return ( + (i[o] = function (...e) { + return ( + s || t.apply(this, e), (t = t.bind(this)), r.apply(this, [t, ...e]) + ); + }), + !0 + ); + } + if (typeof window == 'undefined') throw 'Not in a browser.'; + var p = 'onscrollend' in window; + if (!p) { + let s = function (e, u, l) { + if (u !== 'scrollend') { + e.apply(this, [u, l]); + return; + } + let c = this, + n = i.get(c); + if (!n) { + let d; + (n = { + scrollFn: () => { + clearTimeout(d), + (d = setTimeout(() => { + l(); + }, 100)); + }, + handlers: [l], + }), + e.apply(c, ['scroll', n.scrollFn, !1]), + i.set(c, n); + } + }, + t = function (e, u, l) { + if (u !== 'scrollend') { + e.apply(this, [u, l]); + return; + } + let c = this, + n = i.get(c); + if (n) { + if ( + (typeof n.scrollFn == 'function' && + e.apply(this, ['scroll', n.scrollFn]), + typeof l == 'undefined') + ) + n.handlers = []; + else { + let d = n.handlers.indexOf(l); + d > -1 && n.handlers.splice(d, 1); + } + n.handlers.length === 0 && i.delete(c); + } + }; + (a = s), (w = t); + let i = new WeakMap(), + o = null, + r = null; + f(window, 'addEventListener', s, !0), + f(window, 'removeEventListener', t, !0), + Object.defineProperty(window, 'onscrollend', { + set: e => { + (typeof e != 'function' || o) && + t.call(window, window.removeEventListener, 'scrollend', o), + (o = e), + e && s.call(window, window.addEventListener, 'scrollend', e); + }, + get: () => o, + }), + f(document, 'addEventListener', s, !0), + f(document, 'removeEventListener', t, !0), + Object.defineProperty(document, 'onscrollend', { + set: e => { + (typeof e != 'function' || r) && + t.call(document, document.removeEventListener, 'scrollend', r), + (r = e), + e && s.call(document, document.addEventListener, 'scrollend', e); + }, + get: () => r, + }); + } + var a, w; +})(); diff --git a/src/screens/library/LibraryScreen.tsx b/src/screens/library/LibraryScreen.tsx index d84c130068..f9a4b89011 100644 --- a/src/screens/library/LibraryScreen.tsx +++ b/src/screens/library/LibraryScreen.tsx @@ -140,7 +140,10 @@ const LibraryScreen = ({ navigation }: LibraryScreenProps) => { }, [currentNovels, navigation]); // If there are categories but the current index is out of bounds, set it to 0 - if (categories.length && !categories[index]) setIndex(0); + if (categories.length && !categories[index]) { + setIndex(0); + return null; + } return ( @@ -166,7 +169,7 @@ const LibraryScreen = ({ navigation }: LibraryScreenProps) => { theme={theme} /> - {categories.length && categories[index] ? ( + {categories.length ? ( = ({ }) => { const { inLibrary, isLocal } = novel; const { navigate } = useNavigation(); + const { refreshCategories } = useLibraryContext(); const { tracker } = useTracker(); const { trackedNovel } = useTrackedNovel(novel.id); @@ -145,6 +147,7 @@ const NovelScreenButtonGroup: React.FC = ({ novelIds={[novel.id]} closeModal={closeSetCategoryModal} visible={setCategoryModalVisible} + onSuccess={refreshCategories} /> )} diff --git a/src/screens/reader/components/WebViewReader.tsx b/src/screens/reader/components/WebViewReader.tsx index f760cdb2fd..26a3eb92e7 100644 --- a/src/screens/reader/components/WebViewReader.tsx +++ b/src/screens/reader/components/WebViewReader.tsx @@ -255,6 +255,7 @@ const WebViewReader: React.FC = ({ onPress }) => { }, })} +