element-portable/src
kegsay e946674df3
Store refactor: use non-global stores in components (#9293)
* Add Stores and StoresContext and use it in MatrixChat and RoomView

Added a new kind of class:
- Add God object `Stores` which will hold refs to all known stores and the `MatrixClient`. This object is NOT a singleton.
- Add `StoresContext` to hold onto a ref of `Stores` for use inside components.

`StoresContext` is created via:
- Create `Stores` in `MatrixChat`, assigning the `MatrixClient` when we have one set. Currently sets the RVS to `RoomViewStore.instance`.
- Wrap `MatrixChat`s `render()` function in a `StoresContext.Provider` so it can be used anywhere.

`StoresContext` is currently only used in `RoomView` via the following changes:
- Remove the HOC, which redundantly set `mxClient` as a prop. We don't need this as `RoomView` was using the client from `this.context`.
- Change the type of context accepted from `MatrixClientContext` to `StoresContext`.
- Modify alllll the places where `this.context` is used to interact with the client and suffix `.client`.
- Modify places where we use `RoomViewStore.instance` and replace them with `this.context.roomViewStore`.

This makes `RoomView` use a non-global instance of RVS.

* Linting

* SDKContext and make client an optional constructor arg

* Move SDKContext to /src/contexts

* Inject all RVS deps

* Linting

* Remove reset calls; deep copy the INITIAL_STATE to avoid test pollution

* DI singletons used in RoomView; DI them in RoomView-test too

* Initial RoomViewStore.instance after all files are imported to avoid cyclical deps

* Lazily init stores to allow for circular dependencies

Rather than stores accepting a list of other stores in their constructors,
which doesn't work when A needs B and B needs A, make new-style stores simply
accept Stores. When a store needs another store, they access it via `Stores`
which then lazily constructs that store if it needs it. This breaks the
circular dependency at constructor time, without needing to introduce
wiring diagrams or any complex DI framework.

* Delete RoomViewStore.instance

Replaced with Stores.instance.roomViewStore

* Linting

* Move OverridableStores to test/TestStores

* Rejig how eager stores get made; don't automatically do it else tests break

* Linting

* Linting and review comments

* Fix new code to use Stores.instance

* s/Stores/SdkContextClass/g

* Update docs

* Remove unused imports

* Update src/stores/RoomViewStore.tsx

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>

* Remove empty c'tor to make sonar happy

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2022-10-19 13:07:03 +01:00
..
@types Convert inputs on Export/Import Room Key dialogs to be real Fields (#9350) 2022-10-04 23:28:57 -06:00
accessibility Fix quote shortcut for most keyboard layouts (#9298) 2022-09-29 15:51:50 +00:00
actions Device manager - promote to beta (#9380) 2022-10-11 11:10:55 +02:00
async-components/views/dialogs Convert inputs on Export/Import Room Key dialogs to be real Fields (#9350) 2022-10-04 23:28:57 -06:00
audio Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
autocomplete Use "frequently used emojis" for autocompletion in composer (#8998) 2022-07-21 15:27:11 +02:00
components Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
contexts Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
customisations Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
dispatcher Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
editor Fix soft crash around unknown room pills (#9301) 2022-09-20 17:00:31 +00:00
effects Remove dead code (#9035) 2022-07-11 07:52:44 +02:00
emojipicker Auto fix 2021-10-22 17:23:37 -05:00
events Voice Broadcast live state / extract RelationsHelper (#9432) 2022-10-17 13:31:03 +01:00
hooks Disconnect other connected devices (of the same user) when joining an Element call (#9379) 2022-10-14 15:17:49 +02:00
i18n/strings Device manager - put client/browser device metadata in correct section (#9447) 2022-10-18 13:00:01 +00:00
indexing Document what all of our "Pegs" are (just singletons) (#8510) 2022-05-09 21:34:27 -05:00
integrations Remove Piwik support (#8835) 2022-06-14 17:51:51 +01:00
mjolnir Send stable m.policy.rule.* events instead of mjolnir-prefixed unstable ones (#8300) 2022-04-13 09:10:55 +01:00
models Pass the homeserver's base URL to Element Call (#9429) 2022-10-17 08:18:17 +02:00
modules Support a module API surface for custom functionality (#8246) 2022-07-05 12:26:44 -06:00
notifications Remove dead code (#9035) 2022-07-11 07:52:44 +02:00
performance Add basic performance testing via Cypress (#8586) 2022-05-17 15:38:45 +01:00
rageshake Consolidate random string generation to make Sonar happier (#8675) 2022-05-24 09:05:11 +01:00
resizer Apply corrections identified by SonarQube (#8457) 2022-05-03 22:04:37 +01:00
settings Merge remote-tracking branch 'origin/develop' into feat/add-formating-buttons-to-wysiwyg 2022-10-13 12:42:21 +02:00
stores Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
toasts Device manager - silence call ringers when local notifications are silenced (#9420) 2022-10-17 09:16:04 +00:00
usercontent Eslint - require copyright header rule (#8514) 2022-05-06 09:09:28 +00:00
utils Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
voice-broadcast Add confirm end voice broadcast dialog (#9442) 2022-10-18 09:12:28 +02:00
widgets Implement MSC3819: Allowing widgets to send/receive to-device messages (#8885) 2022-08-10 08:57:56 -04:00
workers Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/ts/c4 2021-07-14 18:36:12 +01:00
AddThreepid.ts Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
AsyncWrapper.tsx Step 3.2: Stop using getComponent in code 2022-03-28 14:02:31 -06:00
Avatar.ts Wire local room logic (#9078) 2022-07-20 09:26:25 +02:00
BasePlatform.ts Add support for disabling spell checking (#8604) 2022-07-28 08:10:04 +00:00
BlurhashEncoder.ts add valuable ts-ignore 2021-07-14 19:16:34 +01:00
boundThreepids.ts Apply corrections identified by SonarQube (#8457) 2022-05-03 22:04:37 +01:00
call-types.ts Step 8.5: Move call event type 2022-03-28 14:02:31 -06:00
ContentMessages.ts Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
createRoom.ts Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
DateUtils.ts Include a file-safe room name and ISO date in chat exports (#9440) 2022-10-17 19:54:10 -06:00
DecryptionFailureTracker.ts Fix all megolm error reported as unknown (#8916) 2022-06-30 08:55:05 +01:00
DeviceListener.ts Device manager - remove client information events when disabling setting (#9384) 2022-10-10 19:00:46 +00:00
Editing.ts Fix issue with redacting via edit composer flow causing stuck editStates (#8184) 2022-03-29 13:33:11 +01:00
email.ts
emoji.ts Upgrade emojibase and twemoji (#7286) 2022-03-23 17:08:34 +00:00
HtmlUtils.tsx Attempt to fix Failed to execute 'removeChild' on 'Node' (#9196) 2022-08-17 13:35:33 +00:00
IConfigOptions.ts Remove piwik config fallback for privacy policy URL (#9390) 2022-10-12 10:08:39 -04:00
identifiers.ts
IdentityAuthClient.tsx Make sonar happier (#9114) 2022-07-29 11:01:15 +00:00
ImageUtils.ts Run a minor code quality checker over the repo (#8524) 2022-05-09 22:52:05 +00:00
index.ts Step 6: Refactor event rendering to stop using getComponent 2022-03-28 14:02:31 -06:00
KeyBindingsDefaults.ts Apply corrections identified by SonarQube (#8457) 2022-05-03 22:04:37 +01:00
KeyBindingsManager.ts Apply corrections identified by SonarQube (#8457) 2022-05-03 22:04:37 +01:00
Keyboard.ts Remove dead code (#9035) 2022-07-11 07:52:44 +02:00
languageHandler.tsx Remove unused packages and fix invariant violation on AsyncStore onNotReady (#9404) 2022-10-13 09:22:32 +01:00
LegacyCallHandler.tsx Device manager - silence call ringers when local notifications are silenced (#9420) 2022-10-17 09:16:04 +00:00
Lifecycle.ts Stabilise Cypress login tests (#9446) 2022-10-18 17:07:23 +01:00
linkify-matrix.ts Delete the remainder of groups (#9357) 2022-10-05 17:44:46 +00:00
Livestream.ts Use & enforce snake_case naming convention on config.json settings (#8062) 2022-03-18 10:12:36 -06:00
Login.ts Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
Markdown.ts Apply corrections identified by SonarQube (#8457) 2022-05-03 22:04:37 +01:00
MatrixClientPeg.ts Implement MSC3575: Sliding Sync (#8328) 2022-09-07 15:42:39 +00:00
MediaDeviceHandler.ts Fix device selection in pre-join screen for Element Call video rooms (#9321) 2022-09-30 17:28:53 +01:00
Modal.tsx Add Voice Broadcast labs setting and composer button (#9279) 2022-09-16 09:10:33 +00:00
NodeAnimator.tsx Eslint - require copyright header rule (#8514) 2022-05-06 09:09:28 +00:00
Notifier.ts Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
PageTypes.ts Delete the remainder of groups (#9357) 2022-10-05 17:44:46 +00:00
PasswordReset.ts Allow user to control if they are signed out of all devices when changing password (#8259) 2022-04-22 18:15:38 +01:00
phonenumber.ts Migrate CountryDropdown to TypeScript 2021-07-15 15:42:11 +02:00
PlatformPeg.ts Fix PlatformSettingsHandler always returning true due to returning a Promise (#8954) 2022-06-30 14:48:21 +00:00
PosthogAnalytics.ts Update matrix-analytics-events to @matrix-org/analytics-events (#8778) 2022-06-07 20:08:36 +01:00
PosthogTrackers.ts Delete the remainder of groups (#9357) 2022-10-05 17:44:46 +00:00
Presence.ts Auto fix 2021-10-22 17:23:37 -05:00
Registration.tsx Remove Piwik support (#8835) 2022-06-14 17:51:51 +01:00
Resend.ts Cancel pending events in virtual room when call placed (#7583) 2022-01-20 09:32:15 +00:00
Roles.ts Auto-fix lint errors 2021-06-29 13:11:58 +01:00
RoomAliasCache.ts
RoomInvite.tsx Remove Piwik support (#8835) 2022-06-14 17:51:51 +01:00
RoomNotifs.ts Remove dead code (#9035) 2022-07-11 07:52:44 +02:00
Rooms.ts Remove dead code (#9035) 2022-07-11 07:52:44 +02:00
ScalarAuthClient.ts Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
ScalarMessaging.ts Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
SdkConfig.ts Voice Broadcast recording pip (#9385) 2022-10-14 18:12:26 +00:00
Searching.ts Auto fix 2021-10-22 17:23:37 -05:00
SecurityManager.ts Remove Piwik support (#8835) 2022-06-14 17:51:51 +01:00
SendHistoryManager.ts Auto fix 2021-10-22 17:23:37 -05:00
sendTimePerformanceMetrics.ts Mandate use of js-sdk/src/matrix import over js-sdk/src (#7933) 2022-03-01 20:42:05 +00:00
sentry.ts Use & enforce snake_case naming convention on config.json settings (#8062) 2022-03-18 10:12:36 -06:00
shouldHideEvent.ts Fix regression of edits showing up in the timeline with hidden events shown (#8260) 2022-04-08 12:10:10 +01:00
SlashCommands.tsx Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
SlidingSyncManager.ts Implement MSC3575: Sliding Sync (#8328) 2022-09-07 15:42:39 +00:00
Terms.ts Remove Piwik support (#8835) 2022-06-14 17:51:51 +01:00
TextForEvent.tsx Add notifications and toasts for Element Call calls (#9337) 2022-10-06 14:27:12 +00:00
theme.ts Add unit tests 2022-09-28 12:46:41 +02:00
Unread.ts Remove deprecated m.room.aliases references (#9431) 2022-10-17 10:58:46 +01:00
UserActivity.ts Auto-fix lint errors 2021-06-29 13:11:58 +01:00
UserAddress.ts Remove dead code (#9035) 2022-07-11 07:52:44 +02:00
verification.ts Prepare utils for local rooms (#9084) 2022-07-25 10:17:40 +02:00
Views.ts Implement Use Case Selection screen (#8984) 2022-07-13 15:43:44 +02:00
VoipUserMapper.ts Prepare for Element Call integration (#9224) 2022-08-30 15:13:39 -04:00
WhoIsTyping.ts Auto-fix lint errors 2021-06-29 13:11:58 +01:00