Space preferences for whether or not you see DMs in a Space (#7250)
This commit is contained in:
parent
5ee356daaa
commit
39c4b78371
22 changed files with 911 additions and 350 deletions
|
@ -184,6 +184,8 @@ export function arrayHasDiff(a: any[], b: any[]): boolean {
|
|||
}
|
||||
}
|
||||
|
||||
export type Diff<T> = { added: T[], removed: T[] };
|
||||
|
||||
/**
|
||||
* Performs a diff on two arrays. The result is what is different with the
|
||||
* first array (`added` in the returned object means objects in B that aren't
|
||||
|
@ -192,7 +194,7 @@ export function arrayHasDiff(a: any[], b: any[]): boolean {
|
|||
* @param b The second array. Must be defined.
|
||||
* @returns The diff between the arrays.
|
||||
*/
|
||||
export function arrayDiff<T>(a: T[], b: T[]): { added: T[], removed: T[] } {
|
||||
export function arrayDiff<T>(a: T[], b: T[]): Diff<T> {
|
||||
return {
|
||||
added: b.filter(i => !a.includes(i)),
|
||||
removed: a.filter(i => !b.includes(i)),
|
||||
|
|
|
@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { arrayDiff, Diff } from "./arrays";
|
||||
|
||||
/**
|
||||
* Determines if two sets are different through a shallow comparison.
|
||||
* @param a The first set. Must be defined.
|
||||
|
@ -32,3 +34,13 @@ export function setHasDiff<T>(a: Set<T>, b: Set<T>): boolean {
|
|||
return true; // different lengths means they are naturally diverged
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the values added and removed between two sets.
|
||||
* @param a The first set. Must be defined.
|
||||
* @param b The second set. Must be defined.
|
||||
* @returns The difference between the values in each set.
|
||||
*/
|
||||
export function setDiff<T>(a: Set<T>, b: Set<T>): Diff<T> {
|
||||
return arrayDiff(Array.from(a), Array.from(b));
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import Spinner from "../components/views/elements/Spinner";
|
|||
import dis from "../dispatcher/dispatcher";
|
||||
import LeaveSpaceDialog from "../components/views/dialogs/LeaveSpaceDialog";
|
||||
import CreateSpaceFromCommunityDialog from "../components/views/dialogs/CreateSpaceFromCommunityDialog";
|
||||
import SpacePreferencesDialog, { SpacePreferenceTab } from "../components/views/dialogs/SpacePreferencesDialog";
|
||||
|
||||
export const shouldShowSpaceSettings = (space: Room) => {
|
||||
const userId = space.client.getUserId();
|
||||
|
@ -197,3 +198,10 @@ export const createSpaceFromCommunity = (cli: MatrixClient, groupId: string): Pr
|
|||
groupId,
|
||||
}, "mx_CreateSpaceFromCommunityDialog_wrapper").finished as Promise<[string?]>;
|
||||
};
|
||||
|
||||
export const showSpacePreferences = (space: Room, initialTabId?: SpacePreferenceTab): Promise<unknown> => {
|
||||
return Modal.createTrackedDialog("Space preferences", "", SpacePreferencesDialog, {
|
||||
initialTabId,
|
||||
space,
|
||||
}, null, false, true).finished;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue