Add message context menu entry to clear events
This commit is contained in:
parent
c83e8e5fd2
commit
db0de237e6
1
TODO.md
1
TODO.md
|
@ -11,6 +11,7 @@
|
||||||
- When qml syntax highlighting supports ES6 string interpolation, use that
|
- When qml syntax highlighting supports ES6 string interpolation, use that
|
||||||
|
|
||||||
- Fixes
|
- Fixes
|
||||||
|
- Quote newline spacing
|
||||||
- 256 min width when a non-image link preview is present
|
- 256 min width when a non-image link preview is present
|
||||||
- Pressing backspace in composer sometimes doesn't work
|
- Pressing backspace in composer sometimes doesn't work
|
||||||
- Message order isn't preserved when sending a first message in a E2E
|
- Message order isn't preserved when sending a first message in a E2E
|
||||||
|
|
1
src/icons/thin/clear-messages.svg
Normal file
1
src/icons/thin/clear-messages.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M11 6.999c2.395.731 4.27 2.607 4.999 5.001.733-2.395 2.608-4.269 5.001-5-2.393-.731-4.268-2.605-5.001-5-.729 2.394-2.604 4.268-4.999 4.999zm7 7c1.437.438 2.562 1.564 2.999 3.001.44-1.437 1.565-2.562 3.001-3-1.436-.439-2.561-1.563-3.001-3-.437 1.436-1.562 2.561-2.999 2.999zm-6 5.501c1.198.365 2.135 1.303 2.499 2.5.366-1.198 1.304-2.135 2.501-2.5-1.197-.366-2.134-1.302-2.501-2.5-.364 1.197-1.301 2.134-2.499 2.5zm-6.001-12.5c-.875 2.873-3.128 5.125-5.999 6.001 2.876.88 5.124 3.128 6.004 6.004.875-2.874 3.128-5.124 5.996-6.004-2.868-.874-5.121-3.127-6.001-6.001z"/></svg>
|
After Width: | Height: | Size: 665 B |
|
@ -64,6 +64,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
self.past_tokens: Dict[str, str] = {} # {room_id: token}
|
self.past_tokens: Dict[str, str] = {} # {room_id: token}
|
||||||
self.fully_loaded_rooms: Set[str] = set() # {room_id}
|
self.fully_loaded_rooms: Set[str] = set() # {room_id}
|
||||||
self.loaded_once_rooms: Set[str] = set() # {room_id}
|
self.loaded_once_rooms: Set[str] = set() # {room_id}
|
||||||
|
self.cleared_events_rooms: Set[str] = set() # {room_id}
|
||||||
|
|
||||||
self.local_echoes_uuid: Set[str] = set()
|
self.local_echoes_uuid: Set[str] = set()
|
||||||
self.resolved_echoes: Dict[str, str] = {} # {event_id: echo_uuid}
|
self.resolved_echoes: Dict[str, str] = {} # {event_id: echo_uuid}
|
||||||
|
@ -225,7 +226,9 @@ class MatrixClient(nio.AsyncClient):
|
||||||
|
|
||||||
|
|
||||||
async def load_past_events(self, room_id: str) -> bool:
|
async def load_past_events(self, room_id: str) -> bool:
|
||||||
if room_id in self.fully_loaded_rooms or room_id in self.invited_rooms:
|
if room_id in self.fully_loaded_rooms or \
|
||||||
|
room_id in self.invited_rooms or \
|
||||||
|
room_id in self.cleared_events_rooms:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
await self.first_sync_done.wait()
|
await self.first_sync_done.wait()
|
||||||
|
@ -379,6 +382,13 @@ class MatrixClient(nio.AsyncClient):
|
||||||
await asyncio.coroutine(cb.func)(room, decrypted)
|
await asyncio.coroutine(cb.func)(room, decrypted)
|
||||||
|
|
||||||
|
|
||||||
|
async def clear_events(self, room_id: str) -> None:
|
||||||
|
self.cleared_events_rooms.add(room_id)
|
||||||
|
model = self.models[Event, self.user_id, room_id]
|
||||||
|
model.clear()
|
||||||
|
model.sync_now()
|
||||||
|
|
||||||
|
|
||||||
# Functions to register data into models
|
# Functions to register data into models
|
||||||
|
|
||||||
async def event_is_past(self, ev: Union[nio.Event, Event]) -> bool:
|
async def event_is_past(self, ev: Union[nio.Event, Event]) -> bool:
|
||||||
|
|
|
@ -6,7 +6,6 @@ import "../../utils.js" as Utils
|
||||||
Column {
|
Column {
|
||||||
id: eventDelegate
|
id: eventDelegate
|
||||||
width: eventList.width
|
width: eventList.width
|
||||||
|
|
||||||
topPadding:
|
topPadding:
|
||||||
model.event_type == "RoomCreateEvent" ? 0 :
|
model.event_type == "RoomCreateEvent" ? 0 :
|
||||||
dayBreak ? theme.spacing * 4 :
|
dayBreak ? theme.spacing * 4 :
|
||||||
|
@ -125,6 +124,14 @@ Column {
|
||||||
Utils.copyToClipboard(selectableLabelContainer.joinedSelection)
|
Utils.copyToClipboard(selectableLabelContainer.joinedSelection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HMenuItem {
|
||||||
|
icon.name: "clear-messages"
|
||||||
|
text: qsTr("Clear messages")
|
||||||
|
onTriggered: py.callClientCoro(
|
||||||
|
chatPage.userId, "clear_events", [chatPage.roomId],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
HMenuItem {
|
HMenuItem {
|
||||||
icon.name: "settings"
|
icon.name: "settings"
|
||||||
text: qsTr("Set as debug console target")
|
text: qsTr("Set as debug console target")
|
||||||
|
|
|
@ -177,7 +177,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
HNoticePage {
|
HNoticePage {
|
||||||
text: qsTr("No messages visible yet")
|
text: qsTr("No messages to show yet")
|
||||||
|
|
||||||
visible: eventList.model.count < 1
|
visible: eventList.model.count < 1
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
Loading…
Reference in New Issue
Block a user