Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Ask to refresh timeline when historical messages are imported (MSC2716) #8354

Closed
Show file tree
Hide file tree
Changes from 84 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
66ea757
Ask to refresh timeline when historical messages are imported (MSC2716)
MadLittleMods Apr 13, 2022
6dba3df
Back to false after getting screenshot
MadLittleMods Apr 13, 2022
12b0115
Fix lints
MadLittleMods Apr 13, 2022
eb5e899
Fix room not showing refresh timeline banner if not switched to the r…
MadLittleMods Apr 13, 2022
a50e011
Fix type lints
MadLittleMods Apr 13, 2022
ed910bb
Remove parenthesis change
MadLittleMods Apr 14, 2022
8d61226
Raw refreshLiveTimeline usage that seems to work
MadLittleMods Apr 16, 2022
d8f94ed
Clean up raw commit
MadLittleMods Apr 18, 2022
c43d309
Merge branch 'develop' into madlittlemods/refresh-timeline-when-we-se…
MadLittleMods Apr 19, 2022
623960b
Clean up event usage
MadLittleMods Apr 19, 2022
d9001ce
Remove unreadable image descriptions
MadLittleMods Apr 19, 2022
b4c81e1
Fix up lints
MadLittleMods Apr 19, 2022
361675e
Add tests for RoomStatusBar
MadLittleMods Apr 19, 2022
bf8555f
Fix lints
MadLittleMods Apr 19, 2022
886b676
Fix lints
MadLittleMods Apr 19, 2022
65cacbb
Match case of other room events
MadLittleMods Apr 20, 2022
cef6d3c
Add types and fix up mis-type
MadLittleMods Apr 20, 2022
f571107
Fix snapshots with using string value case
MadLittleMods Apr 20, 2022
a926252
Merge branch 'develop' into madlittlemods/refresh-timeline-when-we-se…
MadLittleMods May 19, 2022
c2895ff
WIP: Cypress tests
MadLittleMods May 20, 2022
f580947
Register virtual users
MadLittleMods May 21, 2022
4c53f34
All assertions
MadLittleMods May 21, 2022
ee10ae2
Best practice Cypress test selectors
MadLittleMods May 21, 2022
2bdb165
Don't assert text that could change
MadLittleMods May 21, 2022
64e7e28
Send live events sequentially to avoid them all having the same depth
MadLittleMods May 21, 2022
6dbe331
Better self describing message
MadLittleMods May 24, 2022
18adde8
Use function scoped to the tests where it is only used
MadLittleMods May 24, 2022
a661bf6
WIP: Test to make sure racing sync that resolve before /context finis…
MadLittleMods May 24, 2022
ae5338d
The racey sync test does pass, not sure if testing the right thing
MadLittleMods May 24, 2022
f9a525c
Better comments and state of things
MadLittleMods May 24, 2022
b45be5b
More robust to failurse and user feedback
MadLittleMods May 25, 2022
c14cc18
All Cypress tests passing
MadLittleMods May 25, 2022
5286641
Some test cleanup
MadLittleMods May 25, 2022
9ae6483
Merge branch 'develop' into madlittlemods/refresh-timeline-when-we-se…
MadLittleMods May 25, 2022
7848501
Fix some lints
MadLittleMods May 25, 2022
47ecf3b
Remove unused import
MadLittleMods May 25, 2022
2ef47f9
Fix unexpected 'this' lints
MadLittleMods May 26, 2022
e9861c7
Smaller padding
MadLittleMods May 26, 2022
54268ba
Better comment
MadLittleMods May 26, 2022
3defe30
Update snapshots
MadLittleMods May 26, 2022
8461a96
Add test for refreshing the timeline multiple times
MadLittleMods May 26, 2022
4af71c2
Add context into intercepted request error so it's more obvious why y…
MadLittleMods May 26, 2022
0dae43e
Fill in comment doc
MadLittleMods May 26, 2022
e75d92a
Update spapshots after removing last marker processed from js-sdk
MadLittleMods May 26, 2022
b7eb441
Merge branch 'develop' into madlittlemods/refresh-timeline-when-we-se…
MadLittleMods May 27, 2022
7eb0576
Add comments describing why mxSettingsStore is useful
MadLittleMods May 27, 2022
8ed948d
Fix being able to reference Preset
MadLittleMods May 27, 2022
75fc3d4
Save the file
MadLittleMods May 27, 2022
1f4d3b5
Comment out so typescript doesn't go as crazy. Still need to solve th…
MadLittleMods May 27, 2022
17d3203
Remove debug logging
MadLittleMods May 27, 2022
0c5c0b5
Add comment doc to test functions
MadLittleMods May 27, 2022
641d37c
Add snapshot tests for error states
MadLittleMods May 27, 2022
daa0ca7
Fix lints
MadLittleMods May 27, 2022
6c7df4e
Use correct public_baseurl (COPYME template is wrong)
MadLittleMods May 28, 2022
0fac6b2
Only getBot should respond to invites by joining the room
MadLittleMods May 28, 2022
fc0d474
Use spacing variables
MadLittleMods May 28, 2022
0c89bcb
Type unintitialized variable
MadLittleMods May 28, 2022
2008696
Fix minor spacing typo in comments
MadLittleMods Jun 1, 2022
34ebd08
Make sure sentences are properly spaced apart
MadLittleMods Jun 1, 2022
df0522c
Merge branch 'develop' into madlittlemods/refresh-timeline-when-we-se…
MadLittleMods Jul 11, 2022
b9c86ca
Some type cleanup
MadLittleMods Jul 11, 2022
9d7eec3
Update from Modal.createTrackedDialog to Modal.createDialog
MadLittleMods Jul 11, 2022
32952e3
Update snapshots with Matrix client changes
MadLittleMods Jul 11, 2022
7b5ee36
Fix markerEventId typo
MadLittleMods Jul 12, 2022
0e923b7
Fix eventIdWhileRefrshingTimeline typo
MadLittleMods Jul 12, 2022
c9270d8
Add test when we fail to refresh and latest event is a threaded message
MadLittleMods Jul 13, 2022
b44f6a1
Remove the test only
MadLittleMods Jul 13, 2022
ac998bd
Use fire-forget pattern
MadLittleMods Jul 19, 2022
50da54e
Merge branch 'develop' into madlittlemods/refresh-timeline-when-we-se…
MadLittleMods Aug 29, 2022
bbc060f
Merge branch 'develop' into madlittlemods/refresh-timeline-when-we-se…
MadLittleMods Nov 4, 2022
c6e91a1
Merge branch 'develop' into madlittlemods/refresh-timeline-when-we-se…
MadLittleMods Nov 7, 2022
8c78dd5
Make test more robust
MadLittleMods Nov 8, 2022
3d259de
Fix joinRoom duplication
MadLittleMods Nov 8, 2022
e64e59b
Fix duplicate command
MadLittleMods Nov 8, 2022
1ff2c78
Fix some lints
MadLittleMods Nov 8, 2022
ef58f45
Migrate away from enzyme
MadLittleMods Nov 8, 2022
012d27f
Fix more strict errors
MadLittleMods Nov 8, 2022
d2e300b
Update i18n
MadLittleMods Nov 8, 2022
eb815cc
Workaround lint
MadLittleMods Nov 8, 2022
b9cd0a6
More strict lints
MadLittleMods Nov 8, 2022
43f90f6
Use supported room version
MadLittleMods Nov 8, 2022
131af45
Fix lints
MadLittleMods Nov 8, 2022
280ddb5
Fix `Error: TypeError: (0 , _jestMock.mocked)(...).mockReturnValue is…
MadLittleMods Nov 8, 2022
1726830
Update snapshots with small change and lots of quote escaping differe…
MadLittleMods Nov 8, 2022
939a6ef
Merge branch 'develop' into madlittlemods/refresh-timeline-when-we-se…
MadLittleMods Nov 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
819 changes: 819 additions & 0 deletions cypress/e2e/x-msc2716-historical-import/historical-import.spec.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ listeners:
x_forwarded: true

resources:
- names: [client, federation, consent]
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
- names: [client, federation]
compress: false

# An sqlite in-memory database is fast & automatically wipes each time
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Start Synapse with `msc2716_enabled` and an application service configured
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
id: my_application_service_id
hs_token: hs_token123
as_token: as_token123
url: 'http://localhost:0000'
sender_localpart: gitter-badger
namespaces:
users:
- exclusive: false
regex: .*
aliases:
- exclusive: false
regex: .*
rooms:
- exclusive: false
regex: .*
rate_limited: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
server_name: "localhost"
pid_file: /data/homeserver.pid
# XXX: This won't actually be right: it lets docker allocate an ephemeral port,
# so we have a chicken-and-egg problem
public_baseurl: "{{PUBLIC_BASEURL}}"
# Listener is always port 8008 (configured in the container)
listeners:
- port: 8008
tls: false
bind_addresses: ['::']
type: http
x_forwarded: true

resources:
- names: [client, federation]
compress: false

# An sqlite in-memory database is fast & automatically wipes each time
database:
name: "sqlite3"
args:
database: ":memory:"

# Needs to be configured to log to the console like a good docker process
log_config: "/data/log.config"

rc_messages_per_second: 10000
rc_message_burst_count: 10000
rc_registration:
per_second: 10000
burst_count: 10000

rc_login:
address:
per_second: 10000
burst_count: 10000
account:
per_second: 10000
burst_count: 10000
failed_attempts:
per_second: 10000
burst_count: 10000

media_store_path: "/data/media_store"
uploads_path: "/data/uploads"
enable_registration: true
enable_registration_without_verification: true
disable_msisdn_registration: false
# These placeholders will be be replaced with values generated at start
registration_shared_secret: "{{REGISTRATION_SECRET}}"
report_stats: false
macaroon_secret_key: "{{MACAROON_SECRET_KEY}}"
form_secret: "{{FORM_SECRET}}"
# Signing key must be here: it will be generated to this file
signing_key_path: "/data/localhost.signing.key"
email:
enable_notifs: false
smtp_host: "localhost"
smtp_port: 25
smtp_user: "exampleusername"
smtp_pass: "examplepassword"
require_transport_security: False
notif_from: "Your Friendly %(app)s homeserver <noreply@example.com>"
app_name: Matrix
notif_template_html: notif_mail.html
notif_template_text: notif_mail.txt
notif_for_new_users: True
client_base_url: "http://localhost/element"

trusted_key_servers:
- server_name: "matrix.org"
suppress_key_server_warning: true

# A list of application service config files to use
#
app_service_config_files:
- /data/as-registration.yaml

experimental_features:
msc2716_enabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Log configuration for Synapse.
#
# This is a YAML file containing a standard Python logging configuration
# dictionary. See [1] for details on the valid settings.
#
# Synapse also supports structured logging for machine readable logs which can
# be ingested by ELK stacks. See [2] for details.
#
# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema
# [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html

version: 1

formatters:
precise:
format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'

handlers:
# A handler that writes logs to stderr. Unused by default, but can be used
# instead of "buffer" and "file" in the logger handlers.
console:
class: logging.StreamHandler
formatter: precise

loggers:
synapse.storage.SQL:
# beware: increasing this to DEBUG will make synapse log sensitive
# information such as access tokens.
level: INFO

twisted:
# We send the twisted logging directly to the file handler,
# to work around https://github.com/matrix-org/synapse/issues/3471
# when using "buffer" logger. Use "console" to log to stderr instead.
handlers: [console]
propagate: false

root:
level: INFO

# Write logs to the `buffer` handler, which will buffer them together in memory,
# then write them to a file.
#
# Replace "buffer" with "console" to log to stderr instead. (Note that you'll
# also need to update the configuration for the `twisted` logger above, in
# this case.)
#
handlers: [console]

disable_existing_loggers: false
25 changes: 24 additions & 1 deletion cypress/support/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

/// <reference types="cypress" />

import type { ISendEventResponse, MatrixClient, Room } from "matrix-js-sdk/src/matrix";
import type { ISendEventResponse, MatrixClient, Room, IMatrixClientCreateOpts } from "matrix-js-sdk/src/matrix";
import { SynapseInstance } from "../plugins/synapsedocker";
import Chainable = Cypress.Chainable;

Expand Down Expand Up @@ -50,6 +50,14 @@ declare global {
* @param opts create bot options
*/
getBot(synapse: SynapseInstance, opts: CreateBotOpts): Chainable<MatrixClient>;
/**
* Create a new Matrix client to interact with the API as user
* separate from the one logged in
* @param synapse the instance on which to register the bot user
* @param opts Options to pass when creating a new Matrix client
* like `userId` and `accessToken`
*/
newMatrixClient(synapse: SynapseInstance, opts: IMatrixClientCreateOpts): Chainable<MatrixClient>;
/**
* Let a bot join a room
* @param cli The bot's MatrixClient
Expand All @@ -73,6 +81,21 @@ declare global {
}
}

Cypress.Commands.add("newMatrixClient", (
synapse: SynapseInstance,
opts: IMatrixClientCreateOpts,
): Chainable<MatrixClient> => {
return cy.window({ log: false }).then(win => {
const cli = new win.matrixcs.MatrixClient({
...opts,
});

cli.startClient();

return cli;
});
});

Cypress.Commands.add("getBot", (synapse: SynapseInstance, opts: CreateBotOpts): Chainable<MatrixClient> => {
opts = Object.assign({}, defaultCreateBotOptions, opts);
const username = Cypress._.uniqueId("userId_");
Expand Down
54 changes: 43 additions & 11 deletions cypress/support/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { FileType, Upload, UploadOpts } from "matrix-js-sdk/src/http-api";
import type { ICreateRoomOpts, ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
import type { MatrixClient } from "matrix-js-sdk/src/client";
import type { Room } from "matrix-js-sdk/src/models/room";
import type { IJoinRoomOpts } from "matrix-js-sdk/src/@types/requests";
import type { IContent } from "matrix-js-sdk/src/models/event";
import Chainable = Cypress.Chainable;

Expand Down Expand Up @@ -49,6 +50,17 @@ declare global {
* @param userId the id of the user to invite
*/
inviteUser(roomId: string, userId: string): Chainable<{}>;
/**
* Joins the current user to the given room.
* @param roomIdOrAlias the id or alias of the room to join
* @param opts the options when joining a room
*/
joinRoom(roomIdOrAlias: string, opts?: IJoinRoomOpts): Chainable<{}>;
/**
* Waits for the given room to be synced locally
* @param roomId the id of the room to wait for locally
*/
waitForRoom(roomId: string): Chainable<string>;
/**
* Sets account data for the user.
* @param type The type of account data.
Expand Down Expand Up @@ -123,11 +135,6 @@ declare global {
* Boostraps cross-signing.
*/
bootstrapCrossSigning(): Chainable<void>;
/**
* Joins the given room by alias or ID
* @param roomIdOrAlias the id or alias of the room to join
*/
joinRoom(roomIdOrAlias: string): Chainable<Room>;
}
}
}
Expand All @@ -143,11 +150,40 @@ Cypress.Commands.add("getDmRooms", (userId: string): Chainable<string[]> => {
});

Cypress.Commands.add("createRoom", (options: ICreateRoomOpts): Chainable<string> => {
cy.window({ log: false })
.then(async win => {
const cli = win.mxMatrixClientPeg.matrixClient;
const resp = await cli.createRoom(options);
const roomId = resp.room_id;
return roomId;
})
.as('roomId');

return cy.get<string>("@roomId").then(roomId => {
return cy.waitForRoom(roomId);
});
});

Cypress.Commands.add("inviteUser", (roomId: string, userId: string): Chainable<{}> => {
return cy.getClient().then(async (cli: MatrixClient) => {
return cli.invite(roomId, userId);
});
});

Cypress.Commands.add("joinRoom", (roomIdOrAlias: string, opts?: IJoinRoomOpts): Chainable<{}> => {
cy.getClient().then(async (cli: MatrixClient) => {
return cli.joinRoom(roomIdOrAlias, opts);
});

// Wait for the room to be available locally
return cy.waitForRoom(roomIdOrAlias);
});

Cypress.Commands.add("waitForRoom", (roomId: string): Chainable<string> => {
return cy.window({ log: false }).then(async win => {
const cli = win.mxMatrixClientPeg.matrixClient;
const resp = await cli.createRoom(options);
const roomId = resp.room_id;

// Wait for the room to be available locally
if (!cli.getRoom(roomId)) {
await new Promise<void>(resolve => {
const onRoom = (room: Room) => {
Expand Down Expand Up @@ -221,7 +257,3 @@ Cypress.Commands.add("bootstrapCrossSigning", () => {
});
});
});

Cypress.Commands.add("joinRoom", (roomIdOrAlias: string): Chainable<Room> => {
return cy.getClient().then(cli => cli.joinRoom(roomIdOrAlias));
});
8 changes: 8 additions & 0 deletions res/css/structures/_RoomStatusBar.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ limitations under the License.
min-height: 70px;
margin: 12px;
padding-left: 16px;
padding-top: $spacing-4;
padding-bottom: $spacing-4;
background-color: $header-panel-bg-color;
border-radius: 4px;
}
Expand Down Expand Up @@ -145,6 +147,12 @@ limitations under the License.
mask-image: url('$(res)/img/element-icons/retry.svg');
}
}

&.mx_RoomStatusBar_refreshTimelineBtn {
&::before {
mask-image: url('$(res)/img/element-icons/retry.svg');
}
}
}

.mx_InlineSpinner {
Expand Down
2 changes: 1 addition & 1 deletion res/css/structures/_RoomView.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ limitations under the License.
}

.mx_RoomView_statusArea_expanded {
max-height: 100px;
max-height: 140px;
}

.mx_RoomView_statusAreaBox {
Expand Down
4 changes: 3 additions & 1 deletion src/components/structures/FilePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ class FilePanel extends React.Component<IProps, IState> {
}

if (!this.state.timelineSet.eventIdToTimeline(ev.getId())) {
this.state.timelineSet.addEventToTimeline(ev, timeline, false);
this.state.timelineSet.addEventToTimeline(ev, timeline, {
toStartOfTimeline: false,
});
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/structures/LoggedInView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ class LoggedInView extends React.Component<IProps, IState> {

const pinnedEventIds = pinStateEvent.getContent().pinned.slice(0, MAX_PINNED_NOTICES_PER_ROOM);
for (const eventId of pinnedEventIds) {
const timeline = await this._matrixClient.getEventTimeline(room.getUnfilteredTimelineSet(), eventId);
const event = timeline.getEvents().find(ev => ev.getId() === eventId);
await this._matrixClient.getEventTimeline(room.getUnfilteredTimelineSet(), eventId);
const event = room.findEventById(eventId);
if (event) events.push(event);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/structures/MessagePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ interface IProps {

// the userid of our user. This is used to suppress the read marker
// for pending messages.
ourUserId?: string;
ourUserId?: string | null | undefined;

// whether the timeline can visually go back any further
canBackPaginate?: boolean;
Expand All @@ -159,7 +159,7 @@ interface IProps {
stickyBottom?: boolean;

// className for the panel
className: string;
className?: string;

// show twelve hour timestamps
isTwelveHour?: boolean;
Expand All @@ -173,7 +173,7 @@ interface IProps {
// which layout to use
layout?: Layout;

resizeNotifier: ResizeNotifier;
resizeNotifier?: ResizeNotifier;
permalinkCreator?: RoomPermalinkCreator;
editState?: EditorStateTransfer;

Expand All @@ -186,7 +186,7 @@ interface IProps {
// helper function to access relations for an event
onUnfillRequest?(backwards: boolean, scrollToken: string): void;

getRelationsForEvent?(eventId: string, relationType: string, eventType: string): Relations;
getRelationsForEvent?(eventId: string, relationType: string, eventType: EventType | string): Relations;

hideThreadedMessages?: boolean;
disableGrouping?: boolean;
Expand Down
Loading