mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-24 03:55:09 +01:00
fix gap failing to fill 2nd time + unit regression test
This commit is contained in:
parent
15048bd9c3
commit
56495c9d13
@ -72,3 +72,31 @@ export class GapTile extends SimpleTile {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import {FragmentBoundaryEntry} from "../../../../../matrix/room/timeline/entries/FragmentBoundaryEntry.js";
|
||||||
|
export function tests() {
|
||||||
|
return {
|
||||||
|
"uses updated token to fill": async assert => {
|
||||||
|
let currentToken = 5;
|
||||||
|
const fragment = {
|
||||||
|
id: 0,
|
||||||
|
previousToken: currentToken,
|
||||||
|
roomId: "!abc"
|
||||||
|
};
|
||||||
|
const room = {
|
||||||
|
async fillGap(entry) {
|
||||||
|
console.log(entry.token, currentToken);
|
||||||
|
assert.equal(entry.token, currentToken);
|
||||||
|
currentToken += 1;
|
||||||
|
const newEntry = entry.withUpdatedFragment(Object.assign({}, fragment, {previousToken: currentToken}));
|
||||||
|
tile.updateEntry(newEntry);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const tile = new GapTile({entry: new FragmentBoundaryEntry(fragment, true), room});
|
||||||
|
await tile.fill();
|
||||||
|
await tile.fill();
|
||||||
|
await tile.fill();
|
||||||
|
assert.equal(currentToken, 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -85,7 +85,7 @@ export class SimpleTile extends ViewModel {
|
|||||||
// update received for already included (falls within sort keys) entry
|
// update received for already included (falls within sort keys) entry
|
||||||
updateEntry(entry, param) {
|
updateEntry(entry, param) {
|
||||||
const renderedAsRedacted = this.shape === "redacted";
|
const renderedAsRedacted = this.shape === "redacted";
|
||||||
if (entry.isRedacted !== renderedAsRedacted) {
|
if (!entry.isGap && entry.isRedacted !== renderedAsRedacted) {
|
||||||
// recreate the tile if the entry becomes redacted
|
// recreate the tile if the entry becomes redacted
|
||||||
return UpdateAction.Replace("shape");
|
return UpdateAction.Replace("shape");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user