Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 38d61d4
Author: Mirian Margiani <[email protected]>
Date:   Mon Dec 2 12:59:30 2024 +0100

    Hide less important unhandled events from the timeline

    Signed-off-by: Mirian Margiani <[email protected]>

commit 5817d68
Author: Mirian Margiani <[email protected]>
Date:   Mon Dec 2 12:59:29 2024 +0100

    Render unknown events without sender avatar as announcements

    Signed-off-by: Mirian Margiani <[email protected]>

commit 9c7da1c
Author: Mirian Margiani <[email protected]>
Date:   Mon Dec 2 12:59:28 2024 +0100

    Render unknown message types

    This helps users not to miss anything unnoticed. Clearly state
    that a message is not supported by hydrogen so users can check
    their messages with a different client.

    Signed-off-by: Mirian Margiani <[email protected]>

commit cd02ef6
Merge: 4ae47c0 58af591
Author: R Midhun Suresh <[email protected]>
Date:   Mon Oct 21 17:25:32 2024 +0530

    Merge pull request element-hq#1190 from element-hq/sdk-release/0.3.1

    Changes for sdk-release 0.3.1

commit 58af591
Author: R Midhun Suresh <[email protected]>
Date:   Mon Oct 21 17:23:57 2024 +0530

    Changes for sdk-release 0.3.1
  • Loading branch information
b100dian committed Dec 2, 2024
1 parent 0a14b49 commit 06aeaf5
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/domain/session/room/timeline/tiles/ITile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export enum TileShape {
DateHeader = "date-header",
Call = "call",
Verification = "verification",
UnknownEvent = "unknown-event",
}

// TODO: should we imply inheriting from view model here?
Expand Down
35 changes: 35 additions & 0 deletions src/domain/session/room/timeline/tiles/UnknownEventTile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright 2024 Mirian Margiani <[email protected]>
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 {SimpleTile} from "./SimpleTile";

export class UnknownEventTile extends SimpleTile {

get shape() {
return "unknown-event";
}

get details() {
const eventType = this._entry.eventType;
const content = this._entry.content;

if (content.msgtype) {
return this.i18n`This message is not supported by your app (event “${eventType}”, message type “${content.msgtype}”). Please report this issue.`
} else {
return this.i18n`This message is not supported by your app (event “${eventType}”). Please report this issue.`
}
}
}
30 changes: 26 additions & 4 deletions src/domain/session/room/timeline/tiles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {EncryptionEnabledTile} from "./EncryptionEnabledTile.js";
import {MissingAttachmentTile} from "./MissingAttachmentTile.js";
import {CallTile} from "./CallTile.js";
import {VerificationTile} from "./VerificationTile.js";
import {UnknownEventTile} from "./UnknownEventTile.js";

import type {ITile, TileShape} from "./ITile";
import type {Room} from "../../../../../matrix/room/Room";
Expand Down Expand Up @@ -82,8 +83,7 @@ export function tileClassForEntry(entry: TimelineEntry, options: Options): TileC
}
return VerificationTile as unknown as TileConstructor;
default:
// unknown msgtype not rendered
return undefined;
return UnknownEventTile;
}
}
case "m.room.name":
Expand All @@ -105,9 +105,31 @@ export function tileClassForEntry(entry: TimelineEntry, options: Options): TileC
}
return undefined;
}
default:
// unknown type not rendered

// These events are handled separately and don't need an extra timeline entry.
case "m.reaction":
case "m.room.redaction":
return undefined;

// Displaying these events is not supported but they can safely be
// hidden instead of spamming rooms with warning messages.
case "m.room.create":
case "m.room.power_levels":
case "m.room.join_rules":
case "m.room.history_visibility":
case "m.room.guest_access":
case "m.room.topic":
case "m.room.avatar":
case "m.bridge":
case "uk.half-shot.bridge":
return undefined;

// Unknown events are rendered as a placeholder so users notice that
// there is something that they are missing. Ideally, all events
// are either added to the "safe-to-ignore" list above, or rendered
// with proper tile implementations.
default:
return UnknownEventTile;
}
}
}
3 changes: 3 additions & 0 deletions src/platform/web/ui/session/room/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {GapView} from "./timeline/GapView.js";
import {CallTileView} from "./timeline/CallTileView";
import {DateHeaderView} from "./timeline/DateHeaderView";
import {VerificationTileView} from "./timeline/VerificationTileView";
import {UnknownEventView} from "./timeline/UnknownEventView";
import type {TileViewConstructor} from "./TimelineView";

export function viewClassForTile(vm: ITile): TileViewConstructor {
Expand Down Expand Up @@ -56,6 +57,8 @@ export function viewClassForTile(vm: ITile): TileViewConstructor {
return DateHeaderView;
case TileShape.Verification:
return VerificationTileView;
case TileShape.UnknownEvent:
return UnknownEventView;
default:
throw new Error(`Tiles of shape "${vm.shape}" are not supported, check the tileClassForEntry function in the view model`);
}
Expand Down
41 changes: 41 additions & 0 deletions src/platform/web/ui/session/room/timeline/UnknownEventView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright 2020 Bruno Windels <[email protected]>
Copyright 2024 Mirian Margiani <[email protected]>
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 {BaseMessageView} from "./BaseMessageView.js";
import {Menu} from "../../../general/Menu.js";

export class UnknownEventView extends BaseMessageView {
render(t, vm) {
if (vm.displayName && vm.avatarUrl) {
super.render(t, vm);
} else {
return t.li({
className: "AnnouncementView",
'data-event-id': vm.eventId
}, t.div(vm => vm.details));
}
}

renderMessageBody(t) {
return t.p({className: "Timeline_messageBody statusMessage"}, vm => vm.details);
}

createMenuOptions(vm) {
const options = super.createMenuOptions(vm);
return options;
}
}

0 comments on commit 06aeaf5

Please sign in to comment.