forked from mystiq/hydrogen-web
render redacted messages
This commit is contained in:
parent
94b0bc82ef
commit
780ad44032
4 changed files with 41 additions and 2 deletions
27
src/domain/session/room/timeline/tiles/RedactedTile.js
Normal file
27
src/domain/session/room/timeline/tiles/RedactedTile.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
Copyright 2020 Bruno Windels <bruno@windels.cloud>
|
||||||
|
|
||||||
|
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 {BaseTextTile} from "./BaseTextTile.js";
|
||||||
|
|
||||||
|
export class RedactedTile extends BaseTextTile {
|
||||||
|
get shape() {
|
||||||
|
return "message-status"
|
||||||
|
}
|
||||||
|
|
||||||
|
_getBodyAsString() {
|
||||||
|
return "This message has been deleted.";
|
||||||
|
}
|
||||||
|
}
|
|
@ -84,8 +84,13 @@ export class SimpleTile extends ViewModel {
|
||||||
|
|
||||||
// update received for already included (falls within sort keys) entry
|
// update received for already included (falls within sort keys) entry
|
||||||
updateEntry(entry, params) {
|
updateEntry(entry, params) {
|
||||||
this._entry = entry;
|
if (entry.isRedacted) {
|
||||||
return UpdateAction.Update(params);
|
// recreate the tile if the entry becomes redacted
|
||||||
|
return UpdateAction.Replace(params);
|
||||||
|
} else {
|
||||||
|
this._entry = entry;
|
||||||
|
return UpdateAction.Update(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return whether the tile should be removed
|
// return whether the tile should be removed
|
||||||
|
|
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||||
|
|
||||||
import {GapTile} from "./tiles/GapTile.js";
|
import {GapTile} from "./tiles/GapTile.js";
|
||||||
import {TextTile} from "./tiles/TextTile.js";
|
import {TextTile} from "./tiles/TextTile.js";
|
||||||
|
import {RedactedTile} from "./tiles/RedactedTile.js";
|
||||||
import {ImageTile} from "./tiles/ImageTile.js";
|
import {ImageTile} from "./tiles/ImageTile.js";
|
||||||
import {VideoTile} from "./tiles/VideoTile.js";
|
import {VideoTile} from "./tiles/VideoTile.js";
|
||||||
import {FileTile} from "./tiles/FileTile.js";
|
import {FileTile} from "./tiles/FileTile.js";
|
||||||
|
@ -31,6 +32,8 @@ export function tilesCreator(baseOptions) {
|
||||||
const options = Object.assign({entry, emitUpdate}, baseOptions);
|
const options = Object.assign({entry, emitUpdate}, baseOptions);
|
||||||
if (entry.isGap) {
|
if (entry.isGap) {
|
||||||
return new GapTile(options);
|
return new GapTile(options);
|
||||||
|
} else if (entry.isRedacted) {
|
||||||
|
return new RedactedTile(options);
|
||||||
} else if (entry.isPending && entry.pendingEvent.isMissingAttachments) {
|
} else if (entry.isPending && entry.pendingEvent.isMissingAttachments) {
|
||||||
return new MissingAttachmentTile(options);
|
return new MissingAttachmentTile(options);
|
||||||
} else if (entry.eventType) {
|
} else if (entry.eventType) {
|
||||||
|
|
|
@ -112,4 +112,8 @@ export class EventEntry extends BaseEntry {
|
||||||
get relatedEventId() {
|
get relatedEventId() {
|
||||||
return this._eventEntry.event.redacts;
|
return this._eventEntry.event.redacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isRedacted() {
|
||||||
|
return !!this._eventEntry.event.unsigned?.redacted_because;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue