Delete the remainder of groups (#9357)
* Delete the remainder of groups Fixes https://github.com/vector-im/element-web/issues/22770 Continues https://github.com/matrix-org/matrix-react-sdk/pull/8027 * Don't need the strings either
This commit is contained in:
parent
bd270b08df
commit
f92f7beb47
15 changed files with 4 additions and 202 deletions
|
@ -43,17 +43,11 @@ export default class ElementPermalinkConstructor extends PermalinkConstructor {
|
|||
return `${this.elementUrl}/#/user/${userId}`;
|
||||
}
|
||||
|
||||
forGroup(groupId: string): string {
|
||||
return `${this.elementUrl}/#/group/${groupId}`;
|
||||
}
|
||||
|
||||
forEntity(entityId: string): string {
|
||||
if (entityId[0] === '!' || entityId[0] === '#') {
|
||||
return this.forRoom(entityId);
|
||||
} else if (entityId[0] === '@') {
|
||||
return this.forUser(entityId);
|
||||
} else if (entityId[0] === '+') {
|
||||
return this.forGroup(entityId);
|
||||
} else throw new Error("Unrecognized entity");
|
||||
}
|
||||
|
||||
|
@ -107,8 +101,6 @@ export default class ElementPermalinkConstructor extends PermalinkConstructor {
|
|||
const eventId = parts.length > 2 ? parts.slice(2).join('/') : "";
|
||||
const via = query.split(/&?via=/).filter(p => !!p);
|
||||
return PermalinkParts.forEvent(entity, eventId, via);
|
||||
} else if (entityType === 'group') {
|
||||
return PermalinkParts.forGroup(entity);
|
||||
} else {
|
||||
throw new Error("Unknown entity type in permalink");
|
||||
}
|
||||
|
|
|
@ -51,10 +51,6 @@ export default class MatrixSchemePermalinkConstructor extends PermalinkConstruct
|
|||
return `matrix:${this.encodeEntity(userId)}`;
|
||||
}
|
||||
|
||||
forGroup(groupId: string): string {
|
||||
throw new Error("Deliberately not implemented");
|
||||
}
|
||||
|
||||
forEntity(entityId: string): string {
|
||||
return `matrix:${this.encodeEntity(entityId)}`;
|
||||
}
|
||||
|
|
|
@ -39,10 +39,6 @@ export default class MatrixToPermalinkConstructor extends PermalinkConstructor {
|
|||
return `${baseUrl}/#/${userId}`;
|
||||
}
|
||||
|
||||
forGroup(groupId: string): string {
|
||||
return `${baseUrl}/#/${groupId}`;
|
||||
}
|
||||
|
||||
forEntity(entityId: string): string {
|
||||
return `${baseUrl}/#/${entityId}`;
|
||||
}
|
||||
|
@ -82,8 +78,6 @@ export default class MatrixToPermalinkConstructor extends PermalinkConstructor {
|
|||
const via = query.split(/&?via=/g).filter(p => !!p);
|
||||
|
||||
return PermalinkParts.forEvent(entity, eventId, via);
|
||||
} else if (entity[0] === '+') {
|
||||
return PermalinkParts.forGroup(entity);
|
||||
} else {
|
||||
throw new Error("Unknown entity type in permalink");
|
||||
}
|
||||
|
|
|
@ -27,10 +27,6 @@ export default class PermalinkConstructor {
|
|||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
forGroup(groupId: string): string {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
forUser(userId: string): string {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
@ -55,30 +51,24 @@ export class PermalinkParts {
|
|||
eventId: string;
|
||||
userId: string;
|
||||
viaServers: string[];
|
||||
groupId: string;
|
||||
|
||||
constructor(roomIdOrAlias: string, eventId: string, userId: string, groupId: string, viaServers: string[]) {
|
||||
constructor(roomIdOrAlias: string, eventId: string, userId: string, viaServers: string[]) {
|
||||
this.roomIdOrAlias = roomIdOrAlias;
|
||||
this.eventId = eventId;
|
||||
this.userId = userId;
|
||||
this.groupId = groupId;
|
||||
this.viaServers = viaServers;
|
||||
}
|
||||
|
||||
static forUser(userId: string): PermalinkParts {
|
||||
return new PermalinkParts(null, null, userId, null, null);
|
||||
}
|
||||
|
||||
static forGroup(groupId: string): PermalinkParts {
|
||||
return new PermalinkParts(null, null, null, groupId, null);
|
||||
return new PermalinkParts(null, null, userId, null);
|
||||
}
|
||||
|
||||
static forRoom(roomIdOrAlias: string, viaServers: string[] = []): PermalinkParts {
|
||||
return new PermalinkParts(roomIdOrAlias, null, null, null, viaServers);
|
||||
return new PermalinkParts(roomIdOrAlias, null, null, viaServers);
|
||||
}
|
||||
|
||||
static forEvent(roomId: string, eventId: string, viaServers: string[] = []): PermalinkParts {
|
||||
return new PermalinkParts(roomId, eventId, null, null, viaServers);
|
||||
return new PermalinkParts(roomId, eventId, null, viaServers);
|
||||
}
|
||||
|
||||
get primaryEntityId(): string {
|
||||
|
|
|
@ -295,10 +295,6 @@ export function makeRoomPermalink(roomId: string): string {
|
|||
return permalinkCreator.forShareableRoom();
|
||||
}
|
||||
|
||||
export function makeGroupPermalink(groupId: string): string {
|
||||
return getPermalinkConstructor().forGroup(groupId);
|
||||
}
|
||||
|
||||
export function isPermalinkHost(host: string): boolean {
|
||||
// Always check if the permalink is a spec permalink (callers are likely to call
|
||||
// parsePermalink after this function).
|
||||
|
@ -319,7 +315,6 @@ export function tryTransformEntityToPermalink(entity: string): string {
|
|||
// Check to see if it is a bare entity for starters
|
||||
if (entity[0] === '#' || entity[0] === '!') return makeRoomPermalink(entity);
|
||||
if (entity[0] === '@') return makeUserPermalink(entity);
|
||||
if (entity[0] === '+') return makeGroupPermalink(entity);
|
||||
|
||||
if (entity.slice(0, 7) === "matrix:") {
|
||||
try {
|
||||
|
@ -332,8 +327,6 @@ export function tryTransformEntityToPermalink(entity: string): string {
|
|||
pl += new MatrixToPermalinkConstructor().encodeServerCandidates(permalinkParts.viaServers);
|
||||
}
|
||||
return pl;
|
||||
} else if (permalinkParts.groupId) {
|
||||
return matrixtoBaseUrl + `/#/${permalinkParts.groupId}`;
|
||||
} else if (permalinkParts.userId) {
|
||||
return matrixtoBaseUrl + `/#/${permalinkParts.userId}`;
|
||||
}
|
||||
|
@ -381,8 +374,6 @@ export function tryTransformPermalinkToLocalHref(permalink: string): string {
|
|||
}
|
||||
} else if (permalinkParts.userId) {
|
||||
permalink = `#/user/${permalinkParts.userId}`;
|
||||
} else if (permalinkParts.groupId) {
|
||||
permalink = `#/group/${permalinkParts.groupId}`;
|
||||
} // else not a valid permalink for our purposes - do not handle
|
||||
}
|
||||
} catch (e) {
|
||||
|
@ -410,7 +401,6 @@ export function getPrimaryPermalinkEntity(permalink: string): string {
|
|||
if (!permalinkParts) return null; // not processable
|
||||
if (permalinkParts.userId) return permalinkParts.userId;
|
||||
if (permalinkParts.roomIdOrAlias) return permalinkParts.roomIdOrAlias;
|
||||
if (permalinkParts.groupId) return permalinkParts.groupId;
|
||||
} catch (e) {
|
||||
// no entity - not a permalink
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue