This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 830
Add stable unstable feature for jump to date before v1.6
is fully supported on a homeserver
#10398
Merged
MadLittleMods
merged 4 commits into
develop
from
madlittlemods/add-stable-unstable-version-for-jump-to-date
Mar 17, 2023
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6462901
MSC3030 jump to date stable is part of Matrix v1.6
MadLittleMods 6e24e29
Add stable unstable identifier while stable support is available whil…
MadLittleMods e4589bb
Any one of the feature groups with required features can enable a set…
MadLittleMods 82b0252
Merge branch 'develop' into madlittlemods/add-stable-unstable-version…
MadLittleMods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,12 +26,21 @@ import SettingsStore from "../SettingsStore"; | |
* When a setting gets disabled or enabled from this controller it notifies the given WatchManager | ||
*/ | ||
export default class ServerSupportUnstableFeatureController extends MatrixClientBackedController { | ||
// Starts off as `undefined` so when we first compare the `newDisabledValue`, it sees | ||
// it as a change and updates the watchers. | ||
private enabled: boolean | undefined; | ||
|
||
/** | ||
* Construct a new ServerSupportUnstableFeatureController. | ||
* | ||
* @param unstableFeatureGroups - If any one of the feature groups is satisfied, | ||
* then the setting is considered enabled. A feature group is satisfied if all of | ||
* the features in the group are supported (all features in a group are required). | ||
*/ | ||
Comment on lines
+36
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As suggested by @t3chguy in #10398 (comment),
Refactoring This way having either If you want to AND features together like before, just add them to the same group: |
||
public constructor( | ||
private readonly settingName: string, | ||
private readonly watchers: WatchManager, | ||
private readonly unstableFeatures: string[], | ||
private readonly unstableFeatureGroups: string[][], | ||
private readonly stableVersion?: string, | ||
private readonly disabledMessage?: string, | ||
private readonly forcedValue: any = false, | ||
|
@@ -43,29 +52,43 @@ export default class ServerSupportUnstableFeatureController extends MatrixClient | |
return !this.enabled; | ||
} | ||
|
||
public set disabled(v: boolean) { | ||
if (!v === this.enabled) return; | ||
this.enabled = !v; | ||
public set disabled(newDisabledValue: boolean) { | ||
if (!newDisabledValue === this.enabled) return; | ||
this.enabled = !newDisabledValue; | ||
const level = SettingsStore.firstSupportedLevel(this.settingName); | ||
if (!level) return; | ||
const settingValue = SettingsStore.getValue(this.settingName, null); | ||
this.watchers.notifyUpdate(this.settingName, null, level, settingValue); | ||
} | ||
|
||
protected async initMatrixClient(oldClient: MatrixClient, newClient: MatrixClient): Promise<void> { | ||
this.disabled = true; | ||
let supported = true; | ||
|
||
// Check for stable version support first | ||
if (this.stableVersion && (await this.client.isVersionSupported(this.stableVersion))) { | ||
this.disabled = false; | ||
return; | ||
} | ||
for (const feature of this.unstableFeatures) { | ||
supported = await this.client.doesServerSupportUnstableFeature(feature); | ||
if (!supported) break; | ||
|
||
// Otherwise, only one of the unstable feature groups needs to be satisfied in | ||
// order for this setting overall to be enabled | ||
let isEnabled = false; | ||
for (const featureGroup of this.unstableFeatureGroups) { | ||
const featureSupportList = await Promise.all( | ||
featureGroup.map(async (feature) => { | ||
const isFeatureSupported = await this.client.doesServerSupportUnstableFeature(feature); | ||
return isFeatureSupported; | ||
}), | ||
); | ||
|
||
// Every feature in a feature group is required in order | ||
// for this setting overall to be enabled. | ||
const isFeatureGroupSatisfied = featureSupportList.every((isFeatureSupported) => isFeatureSupported); | ||
if (isFeatureGroupSatisfied) { | ||
isEnabled = true; | ||
break; | ||
} | ||
} | ||
|
||
this.disabled = !supported; | ||
this.disabled = !isEnabled; | ||
} | ||
|
||
public getValueOverride( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add stable unstable version (
org.matrix.msc3030.stable
) for jump to date beforev1.6
is fully supported on a homeserver.org.matrix.msc3030.stable
wasn't included in MSC3030 but it seems like pattern that should have been included like MSC2285 as an example.Are we okay with moving forward with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related discussion matrix-org/synapse#15283 (comment)