2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-08-18 20:08:14 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { ipcRenderer } from 'electron';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { Middleware } from 'redux';
|
2021-08-18 20:08:14 +00:00
|
|
|
|
2022-09-15 20:10:46 +00:00
|
|
|
import {
|
|
|
|
COLORS_CHANGED,
|
|
|
|
COLOR_SELECTED,
|
|
|
|
SET_VOICE_NOTE_PLAYBACK_RATE,
|
|
|
|
} from '../state/ducks/conversations';
|
2021-08-18 20:08:14 +00:00
|
|
|
|
2021-11-11 22:43:05 +00:00
|
|
|
export const dispatchItemsMiddleware: Middleware =
|
|
|
|
({ getState }) =>
|
|
|
|
next =>
|
|
|
|
action => {
|
|
|
|
const result = next(action);
|
|
|
|
if (
|
|
|
|
action.type === 'items/PUT' ||
|
|
|
|
action.type === 'items/PUT_EXTERNAL' ||
|
|
|
|
action.type === 'items/REMOVE' ||
|
|
|
|
action.type === 'items/REMOVE_EXTERNAL' ||
|
|
|
|
action.type === 'items/RESET' ||
|
|
|
|
action.type === COLOR_SELECTED ||
|
2022-09-15 20:10:46 +00:00
|
|
|
action.type === COLORS_CHANGED ||
|
|
|
|
action.type === SET_VOICE_NOTE_PLAYBACK_RATE
|
2021-11-11 22:43:05 +00:00
|
|
|
) {
|
|
|
|
ipcRenderer.send('preferences-changed', getState().items);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
};
|