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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Threads beta around degraded mode (#8318)
* Hide MAB Threads prompt if user would have degraded mode * Confirm user wants to enable Threads beta if in degraded mode * fix * Fix copy
- Loading branch information
Showing
6 changed files
with
85 additions
and
11 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import * as React from "react"; | ||
import { Thread } from "matrix-js-sdk/src/models/thread"; | ||
|
||
import SettingController from "./SettingController"; | ||
import PlatformPeg from "../../PlatformPeg"; | ||
import { SettingLevel } from "../SettingLevel"; | ||
import Modal from "../../Modal"; | ||
import QuestionDialog from "../../components/views/dialogs/QuestionDialog"; | ||
import { _t } from "../../languageHandler"; | ||
|
||
export default class ThreadBetaController extends SettingController { | ||
public async beforeChange(level: SettingLevel, roomId: string, newValue: any): Promise<boolean> { | ||
if (Thread.hasServerSideSupport || !newValue) return true; // Full support or user is disabling | ||
|
||
const { finished } = Modal.createTrackedDialog<[boolean]>("Thread beta", "degraded mode", QuestionDialog, { | ||
title: _t("Partial Support for Threads"), | ||
description: <> | ||
<p>{ _t("Your homeserver does not currently support threads, so this feature may be unreliable. " + | ||
"Some threaded messages may not be reliably available. <a>Learn more</a>.", {}, { | ||
a: sub => ( | ||
<a href="https://element.io/help#threads" target="_blank" rel="noreferrer noopener">{ sub }</a> | ||
), | ||
}) }</p> | ||
<p>{ _t("Do you want to enable threads anyway?") }</p> | ||
</>, | ||
button: _t("Yes, enable"), | ||
}); | ||
const [enable] = await finished; | ||
return enable; | ||
} | ||
|
||
public onChange(level: SettingLevel, roomId: string, newValue: any) { | ||
// Requires a reload as we change an option flag on the `js-sdk` | ||
// And the entire sync history needs to be parsed again | ||
PlatformPeg.get().reload(); | ||
} | ||
} |