feat(postbox): enforce unified inbox separation
This commit is contained in:
@@ -29,17 +29,22 @@ export default function PostboxInboxWidget({
|
||||
const maxItems = numberSetting(configuration.maxItems, 5, 1, 12);
|
||||
const load = useCallback(async () => {
|
||||
const postboxes = await listPostboxes(settings);
|
||||
if (!postboxes.length) {
|
||||
return { messages: [], total: 0 };
|
||||
const eligible = postboxes.filter(
|
||||
(postbox) => postbox.grouping_policy.mode === "allow"
|
||||
);
|
||||
const separatedCount = postboxes.length - eligible.length;
|
||||
if (!eligible.length) {
|
||||
return { messages: [], total: 0, separatedCount };
|
||||
}
|
||||
return listPostboxMessages(
|
||||
const response = await listPostboxMessages(
|
||||
settings,
|
||||
postboxes.map((postbox) => postbox.id),
|
||||
eligible.map((postbox) => postbox.id),
|
||||
maxItems,
|
||||
0,
|
||||
"",
|
||||
"unread"
|
||||
);
|
||||
return { ...response, separatedCount };
|
||||
}, [maxItems, settings]);
|
||||
const { data, loading, error } = useDashboardWidgetData(load, refreshKey);
|
||||
|
||||
@@ -50,6 +55,11 @@ export default function PostboxInboxWidget({
|
||||
{error}
|
||||
</DismissibleAlert>
|
||||
)}
|
||||
{data?.separatedCount ? (
|
||||
<DismissibleAlert tone="info" dismissible={false}>
|
||||
{data.separatedCount} governed Postbox source{data.separatedCount === 1 ? " is" : "s are"} shown only in separated inbox views.
|
||||
</DismissibleAlert>
|
||||
) : null}
|
||||
<DashboardWidgetList
|
||||
emptyText="No unread Postbox messages."
|
||||
items={(data?.messages ?? []).map((message) => ({
|
||||
|
||||
Reference in New Issue
Block a user