fix: use protocol 0.6.2 and remove chat scroll backports
This commit is contained in:
parent
14de23dd28
commit
d441d1f83f
6 changed files with 8 additions and 86 deletions
|
|
@ -1,42 +0,0 @@
|
|||
diff --git a/dist/chat-viewport.js b/dist/chat-viewport.js
|
||||
index 84fdef2bdf411584349a54362663a379d6778808..e322c2a25c0456ada442bbbff2d49494d0db952b 100644
|
||||
--- a/dist/chat-viewport.js
|
||||
+++ b/dist/chat-viewport.js
|
||||
@@ -74,6 +74,11 @@ export function bindChatViewport(list, options) {
|
||||
chat.markRead(latest.dataset.messageId);
|
||||
}
|
||||
}
|
||||
+ function updateFollowing() {
|
||||
+ if (list.clientHeight && initialized && list.scrollTop !== programmedScroll) {
|
||||
+ following = list.scrollHeight - list.scrollTop - list.clientHeight <= 1;
|
||||
+ }
|
||||
+ }
|
||||
function refresh() {
|
||||
if (disposed || frame !== undefined) {
|
||||
return;
|
||||
@@ -81,11 +86,13 @@ export function bindChatViewport(list, options) {
|
||||
frame = win.requestAnimationFrame(() => {
|
||||
frame = undefined;
|
||||
if (list.clientHeight && chat.snapshot.open && (options.isVisible?.() ?? true)) {
|
||||
+ // Observers can run before the scroll event from a small wheel or touch movement.
|
||||
+ updateFollowing();
|
||||
if (scrollToUnread) {
|
||||
const row = rows().find((element) => chat.snapshot.unreadIds.includes(element.dataset.messageId ?? ""));
|
||||
if (row) {
|
||||
list.scrollTop += row.getBoundingClientRect().top - list.getBoundingClientRect().top;
|
||||
- following = list.scrollHeight - list.scrollTop - list.clientHeight < 32;
|
||||
+ following = list.scrollHeight - list.scrollTop - list.clientHeight <= 1;
|
||||
}
|
||||
else {
|
||||
following = true;
|
||||
@@ -103,9 +110,7 @@ export function bindChatViewport(list, options) {
|
||||
});
|
||||
}
|
||||
function scroll() {
|
||||
- if (list.clientHeight && initialized && list.scrollTop !== programmedScroll) {
|
||||
- following = list.scrollHeight - list.scrollTop - list.clientHeight < 32;
|
||||
- }
|
||||
+ updateFollowing();
|
||||
refresh();
|
||||
}
|
||||
const resize = new ResizeObserver(refresh);
|
||||
|
|
@ -1 +0,0 @@
|
|||
The protocol 0.6.1 patch backports the [shared chat scrolling fix](https://codeberg.org/boardgamers/boardgamers/commit/7b4e1ff6). It prevents slow wheel and touch gestures from snapping back to the newest message. Remove the patch when upgrading to a protocol release containing that fix.
|
||||
|
|
@ -3,4 +3,4 @@ packages:
|
|||
- 'engine'
|
||||
|
||||
minimumReleaseAgeExclude:
|
||||
- '@boardgamers/protocol@0.4.0 || 0.4.2 || 0.5.0 || 0.6.0 || 0.6.1'
|
||||
- '@boardgamers/protocol@0.4.0 || 0.4.2 || 0.5.0 || 0.6.0 || 0.6.1 || 0.6.2'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "powergrid-viewer",
|
||||
"version": "2.1.14",
|
||||
"version": "2.1.15",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/boardgamers/powergrid.git",
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
"tutorial:manifest": "node scripts/tutorial-manifest.cjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.6.1",
|
||||
"@boardgamers/protocol": "0.6.2",
|
||||
"core-js": "^3.6.5",
|
||||
"lodash": "^4.17.19",
|
||||
"powergrid-engine": "workspace:../engine",
|
||||
|
|
@ -65,10 +65,5 @@
|
|||
"dist/media",
|
||||
"tsconfig.json",
|
||||
"public/audio"
|
||||
],
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"@boardgamers/protocol@0.6.1": "../patches/@boardgamers__protocol@0.6.1.patch"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
14
viewer/pnpm-lock.yaml
generated
14
viewer/pnpm-lock.yaml
generated
|
|
@ -1,12 +1,7 @@
|
|||
lockfileVersion: 5.4
|
||||
|
||||
patchedDependencies:
|
||||
'@boardgamers/protocol@0.6.1':
|
||||
hash: oubd3xmna5uo2zbpwuoh2jxdke
|
||||
path: ../patches/@boardgamers__protocol@0.6.1.patch
|
||||
|
||||
specifiers:
|
||||
'@boardgamers/protocol': 0.6.1
|
||||
'@boardgamers/protocol': 0.6.2
|
||||
'@types/assert': ^1.4.7
|
||||
'@types/chai': ^4.2.11
|
||||
'@types/events': ^3.0.0
|
||||
|
|
@ -39,7 +34,7 @@ specifiers:
|
|||
zod: 4.6.4
|
||||
|
||||
dependencies:
|
||||
'@boardgamers/protocol': 0.6.1_oubd3xmna5uo2zbpwuoh2jxdke
|
||||
'@boardgamers/protocol': 0.6.2
|
||||
core-js: 3.12.1
|
||||
lodash: 4.17.21
|
||||
powergrid-engine: link:../engine
|
||||
|
|
@ -1469,15 +1464,14 @@ packages:
|
|||
to-fast-properties: 2.0.0
|
||||
dev: true
|
||||
|
||||
/@boardgamers/protocol/0.6.1_oubd3xmna5uo2zbpwuoh2jxdke:
|
||||
/@boardgamers/protocol/0.6.2:
|
||||
resolution:
|
||||
{
|
||||
integrity: sha512-/SdqqYrRUNizjGqQygR4kxTZqCOqWfj190Uj/YHI8i0pD4eNXGofZJd2QhkB63n0iSRHMvJJRJReadof151wBg==,
|
||||
integrity: sha512-6FKgLsB4guCzNww1rkanhrsLHIdQVajDs1B4qNsYcgtUobTBRM2VPt9T4mlc8ZDX4JDQltvJVHuK7XDZ1J556A==,
|
||||
}
|
||||
dependencies:
|
||||
zod: 4.6.4
|
||||
dev: false
|
||||
patched: true
|
||||
|
||||
/@eslint/eslintrc/0.4.2:
|
||||
resolution:
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
|
||||
// Ongoing version-11 games use this older viewer and its matching embedded engine.
|
||||
// Backport only the shared chat fix; never substitute the current game's rules.
|
||||
const url = 'https://cdn.jsdelivr.net/npm/powergrid-viewer@2.1.5/dist/powergrid-viewer.umd.min.js';
|
||||
const response = await fetch(url);
|
||||
assert.ok(response.ok);
|
||||
const source = await response.text();
|
||||
const expected = '3ff7fe9cbf4214d191f882c4a132877ebb90f2a962159d19ff7b7c55d2971800';
|
||||
assert.equal(createHash('sha256').update(source).digest('hex'), expected, 'Pinned legacy viewer changed');
|
||||
const distance = 'e.scrollHeight-e.scrollTop-e.clientHeight<32';
|
||||
assert.equal(source.split(distance).length - 1, 3, 'Journal, unread positioning and chat following');
|
||||
let patched = source.replaceAll(distance, 'e.scrollHeight-e.scrollTop-e.clientHeight<=1');
|
||||
const refresh = '||void 0===t||t)){if(m){var o=k().find';
|
||||
assert.equal(patched.split(refresh).length - 1, 1, 'Chat viewport refresh');
|
||||
patched = patched.replace(
|
||||
refresh,
|
||||
'||void 0===t||t)){v&&e.scrollTop!==h&&(p=e.scrollHeight-e.scrollTop-e.clientHeight<=1);if(m){var o=k().find'
|
||||
);
|
||||
await mkdir(new URL('../dist/', import.meta.url), { recursive: true });
|
||||
await writeFile(new URL('../dist/powergrid-viewer-2.1.5-scroll.umd.min.js', import.meta.url), patched);
|
||||
console.log('Backported chat and journal scrolling to the unchanged version-11 viewer');
|
||||
Loading…
Add table
Add a link
Reference in a new issue