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
91 changes: 91 additions & 0 deletions android/app/src/main/assets/js/polyfill-onscrollend.js
Original file line number Diff line number Diff line change
@@ -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;
})();
7 changes: 5 additions & 2 deletions src/screens/library/LibraryScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<SafeAreaView excludeBottom>
Expand All @@ -166,7 +169,7 @@ const LibraryScreen = ({ navigation }: LibraryScreenProps) => {
theme={theme}
/>

{categories.length && categories[index] ? (
{categories.length ? (
<LibraryTabs
categories={categories}
index={index}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { NovelScreenProps } from '@navigators/types';
import { useTrackedNovel, useTracker } from '@hooks/persisted';
import Animated, { ZoomIn, ZoomOut } from 'react-native-reanimated';
import { MaterialDesignIconName } from '@type/icon';
import { useLibraryContext } from '@components/Context/LibraryContext';

const NButton = ({
onPress,
Expand Down Expand Up @@ -70,6 +71,7 @@ const NovelScreenButtonGroup: React.FC<NovelScreenButtonGroupProps> = ({
}) => {
const { inLibrary, isLocal } = novel;
const { navigate } = useNavigation<NovelScreenProps['navigation']>();
const { refreshCategories } = useLibraryContext();
const { tracker } = useTracker();
const { trackedNovel } = useTrackedNovel(novel.id);

Expand Down Expand Up @@ -145,6 +147,7 @@ const NovelScreenButtonGroup: React.FC<NovelScreenButtonGroupProps> = ({
novelIds={[novel.id]}
closeModal={closeSetCategoryModal}
visible={setCategoryModalVisible}
onSuccess={refreshCategories}
/>
)}
</>
Expand Down
1 change: 1 addition & 0 deletions src/screens/reader/components/WebViewReader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ const WebViewReader: React.FC<WebViewReaderProps> = ({ onPress }) => {
},
})}
</script>
<script src="${assetsUriPrefix}/js/polyfill-onscrollend.js"></script>
<script src="${assetsUriPrefix}/js/icons.js"></script>
<script src="${assetsUriPrefix}/js/van.js"></script>
<script src="${assetsUriPrefix}/js/text-vibe.js"></script>
Expand Down