kopia lustrzana https://github.com/wagtail/wagtail
Remove CommentApp state `update` util
- The `update` util's types are not compatible with future TS v5 adoption. - This util is simply a wrapper around `Object.assign` and only used in three places. - Instead use the Object.assign in place for simplicity instead and remove the `update` util.pull/10738/head
rodzic
1a95163138
commit
fb340f1971
|
@ -1,7 +1,6 @@
|
||||||
import produce, { enableMapSet, enableES5 } from 'immer';
|
import produce, { enableMapSet, enableES5 } from 'immer';
|
||||||
import type { Annotation } from '../utils/annotation';
|
import type { Annotation } from '../utils/annotation';
|
||||||
import * as actions from '../actions/comments';
|
import * as actions from '../actions/comments';
|
||||||
import { update } from './utils';
|
|
||||||
|
|
||||||
enableES5();
|
enableES5();
|
||||||
enableMapSet();
|
enableMapSet();
|
||||||
|
@ -225,7 +224,7 @@ export const reducer = produce(
|
||||||
if (action.update.newText && action.update.newText.length === 0) {
|
if (action.update.newText && action.update.newText.length === 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
update(comment, action.update);
|
Object.assign(comment, action.update);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -280,7 +279,7 @@ export const reducer = produce(
|
||||||
if (action.update.newText && action.update.newText.length === 0) {
|
if (action.update.newText && action.update.newText.length === 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
update(reply, action.update);
|
Object.assign(reply, action.update);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case actions.DELETE_REPLY: {
|
case actions.DELETE_REPLY: {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import produce from 'immer';
|
import produce from 'immer';
|
||||||
import * as actions from '../actions/settings';
|
import * as actions from '../actions/settings';
|
||||||
import type { Author } from './comments';
|
import type { Author } from './comments';
|
||||||
import { update } from './utils';
|
|
||||||
|
|
||||||
export interface SettingsState {
|
export interface SettingsState {
|
||||||
user: Author | null;
|
user: Author | null;
|
||||||
|
@ -20,7 +19,7 @@ export const reducer = produce(
|
||||||
(draft: SettingsState, action: actions.Action) => {
|
(draft: SettingsState, action: actions.Action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actions.UPDATE_GLOBAL_SETTINGS:
|
case actions.UPDATE_GLOBAL_SETTINGS:
|
||||||
update(draft, action.update);
|
Object.assign(draft, action.update);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
export function update<T>(base: T, updatePartial: Partial<T>): T {
|
|
||||||
return Object.assign(base, updatePartial);
|
|
||||||
}
|
|
Ładowanie…
Reference in New Issue