mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 05:04:57 +08:00
Don't show edit button for hidden edit events (#7226)
This commit is contained in:
parent
82c125c170
commit
5ba2d16ee1
@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MatrixEvent, EventStatus } from 'matrix-js-sdk/src/models/event';
|
import { EventStatus, MatrixEvent } from 'matrix-js-sdk/src/models/event';
|
||||||
|
|
||||||
import { MatrixClientPeg } from '../MatrixClientPeg';
|
import { MatrixClientPeg } from '../MatrixClientPeg';
|
||||||
import shouldHideEvent from "../shouldHideEvent";
|
import shouldHideEvent from "../shouldHideEvent";
|
||||||
import { getHandlerTile, haveTileForEvent } from "../components/views/rooms/EventTile";
|
import { getHandlerTile, haveTileForEvent } from "../components/views/rooms/EventTile";
|
||||||
import SettingsStore from "../settings/SettingsStore";
|
import SettingsStore from "../settings/SettingsStore";
|
||||||
import { EventType } from "matrix-js-sdk/src/@types/event";
|
import { EventType, MsgType, RelationType } from "matrix-js-sdk/src/@types/event";
|
||||||
import { MatrixClient } from 'matrix-js-sdk/src/client';
|
import { MatrixClient } from 'matrix-js-sdk/src/client';
|
||||||
import { Thread } from 'matrix-js-sdk/src/models/thread';
|
import { Thread } from 'matrix-js-sdk/src/models/thread';
|
||||||
import { logger } from 'matrix-js-sdk/src/logger';
|
import { logger } from 'matrix-js-sdk/src/logger';
|
||||||
@ -55,14 +55,17 @@ export function isContentActionable(mxEvent: MatrixEvent): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function canEditContent(mxEvent: MatrixEvent): boolean {
|
export function canEditContent(mxEvent: MatrixEvent): boolean {
|
||||||
if (mxEvent.status === EventStatus.CANCELLED || mxEvent.getType() !== "m.room.message" || mxEvent.isRedacted()) {
|
if (mxEvent.status === EventStatus.CANCELLED ||
|
||||||
|
mxEvent.getType() !== EventType.RoomMessage ||
|
||||||
|
mxEvent.isRedacted() ||
|
||||||
|
mxEvent.isRelation(RelationType.Replace) ||
|
||||||
|
mxEvent.getSender() !== MatrixClientPeg.get().getUserId()
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const content = mxEvent.getOriginalContent();
|
|
||||||
const { msgtype } = content;
|
const { msgtype, body } = mxEvent.getOriginalContent();
|
||||||
return (msgtype === "m.text" || msgtype === "m.emote") &&
|
return (msgtype === MsgType.Text || msgtype === MsgType.Emote) && body && typeof body === 'string';
|
||||||
content.body && typeof content.body === 'string' &&
|
|
||||||
mxEvent.getSender() === MatrixClientPeg.get().getUserId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function canEditOwnEvent(mxEvent: MatrixEvent): boolean {
|
export function canEditOwnEvent(mxEvent: MatrixEvent): boolean {
|
||||||
|
Loading…
Reference in New Issue
Block a user