Show all labs even if incompatible, with appropriate tooltip explaining requirements (#10369)
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
parent
209b65243a
commit
e3930fb8b0
16 changed files with 156 additions and 120 deletions
|
@ -14,12 +14,13 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { _t } from "../../languageHandler";
|
||||
import SettingController from "./SettingController";
|
||||
|
||||
export default class RustCryptoSdkController extends SettingController {
|
||||
public get settingDisabled(): boolean {
|
||||
public get settingDisabled(): boolean | string {
|
||||
// Currently this can only be changed via config.json. In future, we'll allow the user to *enable* this setting
|
||||
// via labs, which will migrate their existing device to the rust-sdk implementation.
|
||||
return true;
|
||||
return _t("Can currently only be enabled via config.json");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ export default class ServerSupportUnstableFeatureController extends MatrixClient
|
|||
private readonly settingName: string,
|
||||
private readonly watchers: WatchManager,
|
||||
private readonly unstableFeatures: string[],
|
||||
private readonly stableVersion?: string,
|
||||
private readonly disabledMessage?: string,
|
||||
private readonly forcedValue: any = false,
|
||||
) {
|
||||
super();
|
||||
|
@ -53,10 +55,16 @@ export default class ServerSupportUnstableFeatureController extends MatrixClient
|
|||
protected async initMatrixClient(oldClient: MatrixClient, newClient: MatrixClient): Promise<void> {
|
||||
this.disabled = true;
|
||||
let supported = true;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
this.disabled = !supported;
|
||||
}
|
||||
|
||||
|
@ -72,7 +80,10 @@ export default class ServerSupportUnstableFeatureController extends MatrixClient
|
|||
return null; // no override
|
||||
}
|
||||
|
||||
public get settingDisabled(): boolean {
|
||||
return this.disabled;
|
||||
public get settingDisabled(): boolean | string {
|
||||
if (this.disabled) {
|
||||
return this.disabledMessage ?? true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,8 +69,9 @@ export default abstract class SettingController {
|
|||
|
||||
/**
|
||||
* Gets whether the setting has been disabled due to this controller.
|
||||
* Can also return a string with the reason the setting is disabled.
|
||||
*/
|
||||
public get settingDisabled(): boolean {
|
||||
public get settingDisabled(): boolean | string {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import { SettingLevel } from "../SettingLevel";
|
|||
import { SlidingSyncOptionsDialog } from "../../components/views/dialogs/SlidingSyncOptionsDialog";
|
||||
import Modal from "../../Modal";
|
||||
import SettingsStore from "../SettingsStore";
|
||||
import { _t } from "../../languageHandler";
|
||||
|
||||
export default class SlidingSyncController extends SettingController {
|
||||
public async beforeChange(level: SettingLevel, roomId: string, newValue: any): Promise<boolean> {
|
||||
|
@ -32,8 +33,12 @@ export default class SlidingSyncController extends SettingController {
|
|||
PlatformPeg.get()?.reload();
|
||||
}
|
||||
|
||||
public get settingDisabled(): boolean {
|
||||
public get settingDisabled(): boolean | string {
|
||||
// Cannot be disabled once enabled, user has been warned and must log out and back in.
|
||||
return SettingsStore.getValue("feature_sliding_sync");
|
||||
if (SettingsStore.getValue("feature_sliding_sync")) {
|
||||
return _t("Log out and back in to disable");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue