stubs 107; history fixes
This commit is contained in:
parent
6034adae3c
commit
966328327e
31
mbchc.mjs
31
mbchc.mjs
|
@ -204,7 +204,7 @@ const/**@type {Complete}*/C = { S_OPTS: {behavior: 'instant'},
|
||||||
|
|
||||||
const/**@type {InputHistory}*/H = { input: undefined, ids: undefined, bottom: undefined, // FIXME ids don't need to be a set, but I'm too tired right now
|
const/**@type {InputHistory}*/H = { input: undefined, ids: undefined, bottom: undefined, // FIXME ids don't need to be a set, but I'm too tired right now
|
||||||
enter: (ic, i, b, is) => yes(H.input = i, H.bottom = b, H.ids = is, ic.readOnly = true, val(ic.parentElement?.parentElement?.dataset, d => d['mbchcMode'] = 'h'), b && void W.ElementScrollToEnd('TextAreaChatLog')),
|
enter: (ic, i, b, is) => yes(H.input = i, H.bottom = b, H.ids = is, ic.readOnly = true, val(ic.parentElement?.parentElement?.dataset, d => d['mbchcMode'] = 'h'), b && void W.ElementScrollToEnd('TextAreaChatLog')),
|
||||||
exit: (ic, r) => yes(ic.readOnly = false, val(ic.parentElement?.parentElement?.dataset, d => del(d, 'mbchcMode')), r && val(H.input, i => ic.value = i), val(H.bottom, b => b && void W.ElementScrollToEnd('TextAreaChatLog')))
|
exit: (ic, r) => yes(ic.readOnly = false, val(ic.parentElement?.parentElement?.dataset, d => del(d, 'mbchcMode')), r && val(H.input, i => ic.value = i), val(H.bottom, b => b && void W.ElementScrollToEnd('TextAreaChatLog')), W.ChatRoomLastMessageIndex = W.ChatRoomLastMessage.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
ass('MBCHC found, aborting loading', W.MBCHC === $)
|
ass('MBCHC found, aborting loading', W.MBCHC === $)
|
||||||
|
@ -660,36 +660,25 @@ const/**@type {SDK.Hook}*/after = (name, f) => mod.hookFunction(name, 0, (na, n)
|
||||||
//D.addEventListener('keydown', event => void this.focus_chat(event)) // Looks like the club got better at this
|
//D.addEventListener('keydown', event => void this.focus_chat(event)) // Looks like the club got better at this
|
||||||
|
|
||||||
mod.hookFunction('ChatRoomScrollHistory', 0, ([up]) => void val(U.ic, ic => { const input = ic.value, history = W.ChatRoomLastMessage
|
mod.hookFunction('ChatRoomScrollHistory', 0, ([up]) => void val(U.ic, ic => { const input = ic.value, history = W.ChatRoomLastMessage
|
||||||
// FIXME later duplicates should override earlier ones
|
|
||||||
// FIXME we'll make it better when the history is a proper ring buffer
|
// FIXME we'll make it better when the history is a proper ring buffer
|
||||||
if (!ic.readOnly) {
|
if (!ic.readOnly) {
|
||||||
const bottom = W.ElementIsScrolledToEnd('TextAreaChatLog')
|
const/**@type {Map<string,number>}*/map = new Map()
|
||||||
if (m_t(input)) {
|
const/**@type {(l: string, i: number, I: string) => boolean}*/ cond = m_t(input) ? (_, i, __) => i > 0 : (l, _, i) => l !== i && l.startsWith(i)
|
||||||
if (history.length < 2) return U.bell()
|
if (m_t(history.reduce((ax, l, i) => cond(l, i, input) ? ax.set(l, i) : ax, map))) return U.bell()
|
||||||
H.enter(ic, input, bottom, mut(new Set(history.keys()), s => s.delete(0))) // J'accuse! ChatRoomLastMessage is a total mess and a half.
|
H.enter(ic, input, W.ElementIsScrolledToEnd('TextAreaChatLog'), new Set(map.values()))
|
||||||
} else {
|
|
||||||
const/**@type {Set<string>}*/lines = new Set() // these only exist to filter duplicates
|
|
||||||
const/**@type {Set<number>}*/ids = new Set()
|
|
||||||
history.forEach((l, i) => l !== input && l.startsWith(input) && cur(lines.size, s => lines.add(l) !== $ && s < lines.size && ids.add(i)))
|
|
||||||
if (m_t(ids)) return U.bell()
|
|
||||||
H.enter(ic, input, bottom, ids)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (ic.readOnly) { // this can't be an else, because we mutate state above. To be honest, this will always be true, but I want to make sure.
|
if (ic.readOnly) { // this can't be an else, because we mutate state above. To be honest, this will always be true, but I want to make sure.
|
||||||
if (H.ids === $) return U.bell() // shouldn't happen?
|
if (H.ids === $) return U.bell() // shouldn't happen?
|
||||||
let found = -1
|
let found = -1
|
||||||
let first = -1
|
let first = -1
|
||||||
let last = -1
|
let last = -1
|
||||||
for (const i of H.ids) {
|
for (const i of H.ids) { // these aren't necessarily in order
|
||||||
if (up) {
|
if (up) {
|
||||||
if (i < W.ChatRoomLastMessageIndex) found = i
|
if (i < W.ChatRoomLastMessageIndex && i > found) found = i // the largest i that is less than index
|
||||||
last = i
|
if (i > last) last = i
|
||||||
} else {
|
} else {
|
||||||
if (first < 0) first = i
|
if (first < 0 || i < first) first = i
|
||||||
if (i > W.ChatRoomLastMessageIndex) {
|
if (i > W.ChatRoomLastMessageIndex && (i < found || found < 0)) found = i // the smallest i that is greater than index
|
||||||
found = i
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found < 0) found = up ? last : first
|
if (found < 0) found = up ? last : first
|
||||||
|
|
8
package-lock.json
generated
8
package-lock.json
generated
|
@ -9,7 +9,7 @@
|
||||||
"version": "107.13.0",
|
"version": "107.13.0",
|
||||||
"license": "SEE LICENSE IN LICENSE",
|
"license": "SEE LICENSE IN LICENSE",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bc-stubs": "^106.0.0",
|
"bc-stubs": "^107.0.0",
|
||||||
"bondage-club-mod-sdk": "^1.2.0",
|
"bondage-club-mod-sdk": "^1.2.0",
|
||||||
"typescript": "^5.5.2",
|
"typescript": "^5.5.2",
|
||||||
"xo": "^0.56.0"
|
"xo": "^0.56.0"
|
||||||
|
@ -1074,9 +1074,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/bc-stubs": {
|
"node_modules/bc-stubs": {
|
||||||
"version": "106.0.0",
|
"version": "107.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/bc-stubs/-/bc-stubs-106.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/bc-stubs/-/bc-stubs-107.0.0.tgz",
|
||||||
"integrity": "sha512-qUbBXFdTZNq+JUGJLpWCiqfMwSDu/i36fcoTtwfbHMV32lSkXsaLgqK7itOpDZIUTWcZhneN4DO2m6Jd7juk7w==",
|
"integrity": "sha512-PUEvMGe7dDm+lKy6YJIWv1xWCOBVt/WAn4xrG8mBUoGobZVBqOrg+x5lOV0HvG9fcBB8K5NEaXMciE5TOTWkBA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"socket.io-client": "4.6.1"
|
"socket.io-client": "4.6.1"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"author": "Mute",
|
"author": "Mute",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bc-stubs": "^106.0.0",
|
"bc-stubs": "^107.0.0",
|
||||||
"bondage-club-mod-sdk": "^1.2.0",
|
"bondage-club-mod-sdk": "^1.2.0",
|
||||||
"typescript": "^5.5.2",
|
"typescript": "^5.5.2",
|
||||||
"xo": "^0.56.0"
|
"xo": "^0.56.0"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user