Skip to content

Conversation

@AlliotTech
Copy link
Contributor

  • Added an undo flow for single-message deletion so users can revert
    accidental deletes within a short window.
  • Moved undo-specific UI behavior (snackbar actions, timers,
    restore) into the Messages page to keep stores UI-agnostic and
    aligned with existing architecture.
image

related issue: #791

@AlliotTech AlliotTech requested a review from a team as a code owner January 13, 2026 04:15
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.15%. Comparing base (ad9b01e) to head (a504dac).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #901   +/-   ##
=======================================
  Coverage   79.15%   79.15%           
=======================================
  Files          56       56           
  Lines        2226     2226           
=======================================
  Hits         1762     1762           
  Misses        360      360           
  Partials      104      104           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@eternal-flame-AD eternal-flame-AD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, please see comments

Copy link
Member

@eternal-flame-AD eternal-flame-AD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any specific difficulties making the delete all button also undoable ? A cursory look it seems like it's just deleting with a magic number -1.

appIndex: false | number
) => {
if (allIndex !== false && this.exists(AllMessages)) {
this.state[AllMessages].messages.splice(allIndex, 0, message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to have: Don't make this assumption here. there is an edge case where if you delete the message, send a new one in and then try to undo the order can get swapped.

No need if it's too complicated

Comment on lines +106 to +117
if (options?.keepalive) {
const response = await authFetch(url, {
method: 'DELETE',
keepalive: true,
credentials: 'include',
});
if (!response.ok) {
throw new Error('Failed to delete message');
}
return;
}
this.snack('Message deleted');
await axios.delete(url);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (options?.keepalive) {
const response = await authFetch(url, {
method: 'DELETE',
keepalive: true,
credentials: 'include',
});
if (!response.ok) {
throw new Error('Failed to delete message');
}
return;
}
this.snack('Message deleted');
await axios.delete(url);
await axios.delete(url, {
fetchOptions: {
keepalive: options?.keepalive,
credentials: 'include',
},
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like Axios is still using the default XHR adapter (no adapter configured), so fetchOptions is ignored and keepalive won’t take effect. 👀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work with

        await axios.delete(config.get('url') + 'message/' + message.id, {
            adapter: 'fetch',
            fetchOptions: {keepalive: true},
        });

@@ -0,0 +1,139 @@
import Button from '@mui/material/Button';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the current implementation is too complex, the storing of indexes seems error prone, as the index changes with each delete and each new message.

I think it should be possible to implement this functionality without modifying the message state for pending deletions and only modify it when there is an actual delete.

I've an idea in mind and will draft something today or later this week.

Copy link
Member

@jmattheis jmattheis Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you have a look at #903

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants