Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
thororen1234 2026-08-06 10:21:00 -04:00
commit 672157173b
No known key found for this signature in database
2 changed files with 39 additions and 27 deletions

View file

@ -65,6 +65,37 @@ function addDeleteStyle() {
}
}
/**
* Clears a message's history (edit + attachments)
*
* if the message was deleted, it will be completely removed from the UI and MessageStore
*/
function clearMessageHistory(msg: MLMessage) {
if (msg.deleted) {
FluxDispatcher.dispatch({
type: "MESSAGE_DELETE",
channelId: msg.channel_id,
messageId: msg.id,
mlDeleted: true
});
} else {
const attachments = msg.attachments?.filter((a: MLAttachment) => !a.deleted);
updateMessage(msg.channel_id, msg.id, { editHistory: [], attachments });
}
}
/**
* checks if a message has any history (deleted or edited)
* @param message the message to check
*
* @returns true if the message has any history, false otherwise
*/
function doesMessageHaveHistory(message: MLMessage): boolean {
return message.deleted || !!message.editHistory?.length || message.attachments?.some((a: MLAttachment) => a.deleted);
}
const REMOVE_HISTORY_ID = "ml-remove-history";
const TOGGLE_DELETE_STYLE_ID = "ml-toggle-style";
const TOGGLE_DIFF_VIEW_ID = "ml-toggle-diff";
@ -73,9 +104,8 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (
props,
) => {
const { message } = props;
const { deleted, editHistory, id, channel_id } = message;
if (!deleted && !editHistory?.length) return;
const { deleted, id, channel_id } = message;
if (!doesMessageHaveHistory(message)) return;
toggle: {
if (!deleted) break toggle;
@ -97,7 +127,7 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (
// toggle per-message diff rendering when the message
// has an edit history and the setting is enabled
if (editHistory?.length && settings.store.showEditDiffs) {
if (doesMessageHaveHistory(message) && settings.store.showEditDiffs) {
const isDisabled = disabledDiffMessages.has(id);
children.push(
<Menu.MenuItem
@ -133,16 +163,7 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (
label={label}
color="danger"
action={() => {
if (deleted) {
FluxDispatcher.dispatch({
type: "MESSAGE_DELETE",
channelId: channel_id,
id,
mlDeleted: true,
});
} else {
updateMessage(channel_id, id, { editHistory: [] });
}
clearMessageHistory(message);
}}
/>,
);
@ -153,7 +174,7 @@ const patchChannelContextMenu: NavContextMenuPatchCallback = (
{ channel },
) => {
const messages = MessageStore.getMessages(channel?.id) as MLMessage[];
if (!messages?.some(msg => msg.deleted || msg.editHistory?.length)) return;
if (!messages?.some(msg => doesMessageHaveHistory(msg))) return;
const group = findGroupChildrenByChildId("mark-channel-read", children) ?? children;
group.push(
@ -163,17 +184,7 @@ const patchChannelContextMenu: NavContextMenuPatchCallback = (
color="danger"
action={() => {
messages.forEach(msg => {
if (msg.deleted)
FluxDispatcher.dispatch({
type: "MESSAGE_DELETE",
channelId: channel.id,
id: msg.id,
mlDeleted: true,
});
else
updateMessage(channel.id, msg.id, {
editHistory: [],
});
clearMessageHistory(msg);
});
}}
/>,

View file

@ -21,7 +21,8 @@ const DefaultEngines = {
GitHub: "https://github.com/search?q=",
Reddit: "https://www.reddit.com/search?q=",
Wikipedia: "https://wikipedia.org/w/index.php?search=",
Startpage: "https://www.startpage.com/sp/search?query="
Startpage: "https://www.startpage.com/sp/search?query=",
Kagi: "https://kagi.com/search?q="
} as const;
const enum ReplacementEngineValue {