Heavily improved search
This commit is contained in:
parent
20981234f6
commit
754bca2c6f
@ -32,6 +32,7 @@ export class AnimeNotifier {
|
|||||||
infiniteScroller: InfiniteScroller
|
infiniteScroller: InfiniteScroller
|
||||||
mainPageLoaded: boolean
|
mainPageLoaded: boolean
|
||||||
isLoading: boolean
|
isLoading: boolean
|
||||||
|
diffCompletedForCurrentPath: boolean
|
||||||
lastReloadContentPath: string
|
lastReloadContentPath: string
|
||||||
currentSoundTrackId: string
|
currentSoundTrackId: string
|
||||||
|
|
||||||
@ -665,31 +666,48 @@ export class AnimeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diff(url: string) {
|
async diff(url: string) {
|
||||||
if(url === this.app.currentPath) {
|
if(url === this.app.currentPath) {
|
||||||
return Promise.reject(null)
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = "/_" + url
|
let path = "/_" + url
|
||||||
let request = this.app.get(path)
|
|
||||||
|
|
||||||
// let request = fetch(path, {
|
try {
|
||||||
// credentials: "same-origin"
|
// Start the request
|
||||||
// })
|
let request = fetch(path, {
|
||||||
// .then(response => response.text())
|
credentials: "same-origin"
|
||||||
|
})
|
||||||
|
.then(response => response.text())
|
||||||
|
|
||||||
history.pushState(url, null, url)
|
history.pushState(url, null, url)
|
||||||
this.app.currentPath = url
|
this.app.currentPath = url
|
||||||
this.app.markActiveLinks()
|
this.diffCompletedForCurrentPath = false
|
||||||
this.unmountMountables()
|
this.app.markActiveLinks()
|
||||||
this.loading(true)
|
this.unmountMountables()
|
||||||
|
this.loading(true)
|
||||||
|
|
||||||
// Delay by transition-speed
|
// Delay by transition-speed
|
||||||
return delay(150).then(() => request)
|
await delay(150)
|
||||||
.then(html => Diff.innerHTML(this.app.content, html))
|
|
||||||
.then(() => this.app.emit("DOMContentLoaded"))
|
let html = await request
|
||||||
.then(() => this.loading(false))
|
|
||||||
.catch(console.error)
|
// If the response for the correct path has not arrived yet, show this response
|
||||||
|
if(!this.diffCompletedForCurrentPath) {
|
||||||
|
// If this response was the most recently requested one, mark the requests as completed
|
||||||
|
if(this.app.currentPath === url) {
|
||||||
|
this.diffCompletedForCurrentPath = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update contents
|
||||||
|
await Diff.innerHTML(this.app.content, html)
|
||||||
|
this.app.emit("DOMContentLoaded")
|
||||||
|
}
|
||||||
|
} catch(err) {
|
||||||
|
console.error(err)
|
||||||
|
} finally {
|
||||||
|
this.loading(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post(url: string, body: any) {
|
post(url: string, body: any) {
|
||||||
|
@ -28,7 +28,11 @@ export class MutationQueue {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mutation(this.elements[i])
|
try {
|
||||||
|
this.mutation(this.elements[i])
|
||||||
|
} catch(err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clear()
|
this.clear()
|
||||||
@ -66,7 +70,11 @@ export class CustomMutationQueue {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mutations[i]()
|
try {
|
||||||
|
this.mutations[i]()
|
||||||
|
} catch(err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clear()
|
this.clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user