v0.11.3 - fix post manager cache not clear when switch booru

This commit is contained in:
defaultkavy 2024-10-21 09:55:50 +08:00
parent 0d63638b82
commit 793d0342ff
Signed by: defaultkavy
GPG Key ID: DFBB22C4E69D7826
5 changed files with 10 additions and 8 deletions

File diff suppressed because one or more lines are too long

2
dist/index.html vendored
View File

@ -16,7 +16,7 @@
gtag('config', 'G-59HBGP98WR'); gtag('config', 'G-59HBGP98WR');
</script> </script>
<script type="module" crossorigin src="/assets/index-B055pf9K.js"></script> <script type="module" crossorigin src="/assets/index-BtOtuQPY.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-Plu04C2a.css"> <link rel="stylesheet" crossorigin href="/assets/index-Plu04C2a.css">
</head> </head>
<body> <body>

View File

@ -2,7 +2,7 @@
"name": "danbooru-viewer", "name": "danbooru-viewer",
"module": "index.ts", "module": "index.ts",
"type": "module", "type": "module",
"version": "0.11.2", "version": "0.11.3",
"scripts": { "scripts": {
"dev": "bun x vite", "dev": "bun x vite",
"build": "bun x vite build", "build": "bun x vite build",

View File

@ -27,10 +27,7 @@ export class $PostGrid extends $Layout {
setInterval(async () => { if (this.inDOM() && document.documentElement.scrollTop === 0) await this.posts.fetchPosts('newer'); }, 10000); setInterval(async () => { if (this.inDOM() && document.documentElement.scrollTop === 0) await this.posts.fetchPosts('newer'); }, 10000);
Booru.events.on('set', () => { Booru.events.on('set', () => {
this.removeAll(); this.removeAll();
if (this.posts.finished) { this.loader();
this.posts.finished = false;
this.loader();
}
}) })
this.on('resize', () => this.resize()) this.on('resize', () => this.resize())
// this.on('afterRender', () => { // this.on('afterRender', () => {
@ -98,7 +95,6 @@ export class $PostGrid extends $Layout {
} }
removeAll() { removeAll() {
this.posts.clear();
this.$posts.clear(); this.$posts.clear();
this.$focus.layer(100).removeAll(); this.$focus.layer(100).removeAll();
this.animate({opacity: [1, 0]}, {duration: 300, easing: 'ease'}, () => this.clear().render()) this.animate({opacity: [1, 0]}, {duration: 300, easing: 'ease'}, () => this.clear().render())

View File

@ -13,6 +13,12 @@ export class PostManager {
constructor(tags?: string) { constructor(tags?: string) {
this.tags = tags; this.tags = tags;
PostManager.managers.set(this.tags, this); PostManager.managers.set(this.tags, this);
Booru.events.on('set', () => {
this.clear();
if (this.finished) {
this.finished = false;
}
})
} }
static get(tags: string | undefined) { static get(tags: string | undefined) {