parent
49f2dc55b8
commit
8da46dffe4
5 changed files with 75 additions and 16 deletions
|
|
@ -97,6 +97,25 @@ class RoomChatController(final ChatParams info)
|
|||
),
|
||||
);
|
||||
|
||||
void hideClientSticky(int eventRowId) => ref
|
||||
.read(RoomsController.provider.notifier)
|
||||
.update(
|
||||
.new({
|
||||
info.roomId: Room(
|
||||
resetClientSticky: true,
|
||||
clientSticky:
|
||||
ref
|
||||
.read(
|
||||
RoomsController.provider.select(
|
||||
(rooms) => rooms[info.roomId]?.clientSticky,
|
||||
),
|
||||
)
|
||||
?.remove(eventRowId) ??
|
||||
.new(),
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
Future<void> paginate(Direction direction) async {
|
||||
if (state.isLoading) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,10 +46,13 @@ class RoomsController extends Notifier<IMap<String, Room>> {
|
|||
roomId,
|
||||
existing?.copyWith(
|
||||
hasMore: incoming.hasMore,
|
||||
clientSticky:
|
||||
(incoming.clientSticky.isEmpty == true
|
||||
clientSticky: incoming.resetClientSticky
|
||||
? incoming.clientSticky
|
||||
: (incoming.clientSticky.isEmpty == true
|
||||
? existing.clientSticky
|
||||
: existing.clientSticky.addAll(incoming.clientSticky))
|
||||
: existing.clientSticky.addAll(
|
||||
incoming.clientSticky,
|
||||
))
|
||||
.removeWhere(
|
||||
(rowId) => incoming.timeline.values.contains(rowId),
|
||||
),
|
||||
|
|
@ -64,6 +67,7 @@ class RoomsController extends Notifier<IMap<String, Room>> {
|
|||
(previousValue[event.key] ?? .new()).addAll(event.value),
|
||||
),
|
||||
),
|
||||
resetClientSticky: false,
|
||||
reset: false,
|
||||
hasFetchedMembers:
|
||||
incoming.hasFetchedMembers || existing.hasFetchedMembers,
|
||||
|
|
|
|||
|
|
@ -228,7 +228,8 @@ extension BuildEventOptions on Event {
|
|||
PowerLevelController.provider(
|
||||
.redaction(targetUser: sender, roomId: roomId),
|
||||
),
|
||||
))
|
||||
) &&
|
||||
!eventId.startsWith("~"))
|
||||
PopupMenuItem(
|
||||
onTap: () => showReasonDialog(
|
||||
title: "Delete Message",
|
||||
|
|
@ -245,6 +246,15 @@ extension BuildEventOptions on Event {
|
|||
),
|
||||
),
|
||||
|
||||
if (eventId.startsWith("~"))
|
||||
PopupMenuItem(
|
||||
onTap: () => ref.watch(notifier).hideClientSticky(rowId),
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.delete, color: danger),
|
||||
title: Text("Hide", style: .new(color: danger)),
|
||||
),
|
||||
),
|
||||
|
||||
PopupMenuItem(
|
||||
onTap: () => showReasonDialog(
|
||||
title: "Report",
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ class const Room({
|
|||
final IMap<int, Event> events = const IMap.empty(),
|
||||
|
||||
final bool reset = false,
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
final bool resetClientSticky = false,
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
final bool hasFetchedState = false,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import "package:material_ui/material_ui.dart";
|
|||
import "package:flutter_hooks/flutter_hooks.dart";
|
||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:nexus/controllers/event.dart";
|
||||
import "package:nexus/controllers/room_chat.dart";
|
||||
import "package:nexus/controllers/rooms.dart";
|
||||
import "package:nexus/helpers/extensions/show_context_menu.dart";
|
||||
import "package:nexus/helpers/hooks/chat_scroll.dart";
|
||||
|
|
@ -270,12 +271,35 @@ class const EventRenderer(
|
|||
if (event.sendError != null && event.sendError != "not sent")
|
||||
Padding(
|
||||
padding: .only(bottom: 4),
|
||||
child: Text(
|
||||
child: Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
event.sendError!,
|
||||
style: theme.textTheme.labelSmall?.copyWith(
|
||||
color: theme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
child: Text(
|
||||
"Hide",
|
||||
style: theme.textTheme.labelSmall?.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
decoration: .underline,
|
||||
decorationColor: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
onTap: () => ref
|
||||
.read(
|
||||
RoomChatController.provider((
|
||||
roomId: roomId,
|
||||
contextualEvent: null,
|
||||
)).notifier,
|
||||
)
|
||||
.hideClientSticky(event.rowId),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
].map((child) => Padding(padding: .only(left: 4), child: child)),
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue