mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 23:09:26 +08:00
58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
import IgnoreUserAction from './containers/IgnoreUserAction';
|
|
import IgnoreUserConfirmation from './containers/IgnoreUserConfirmation';
|
|
import IgnoredUserSection from './containers/IgnoredUserSection';
|
|
import translations from './translations.yml';
|
|
import update from 'immutability-helper';
|
|
|
|
export default {
|
|
slots: {
|
|
authorMenuActions: [IgnoreUserAction],
|
|
ignoreUserConfirmation: [IgnoreUserConfirmation],
|
|
profileSections: [IgnoredUserSection],
|
|
},
|
|
translations,
|
|
mutations: {
|
|
IgnoreUser: ({ variables }) => ({
|
|
updateQueries: {
|
|
CoralEmbedStream_Embed: previousData => {
|
|
const ignoredUserId = variables.id;
|
|
const updated = update(previousData, {
|
|
me: {
|
|
ignoredUsers: {
|
|
$push: [
|
|
{
|
|
id: ignoredUserId,
|
|
__typename: 'User',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
});
|
|
return updated;
|
|
},
|
|
},
|
|
}),
|
|
StopIgnoringUser: ({ variables }) => ({
|
|
updateQueries: {
|
|
CoralEmbedStream_Profile: previousData => {
|
|
const noLongerIgnoredUserId = variables.id;
|
|
|
|
// remove noLongerIgnoredUserId from ignoredUsers
|
|
const updated = update(previousData, {
|
|
me: {
|
|
ignoredUsers: {
|
|
$apply: ignoredUsers => {
|
|
return ignoredUsers.filter(
|
|
u => u.id !== noLongerIgnoredUserId
|
|
);
|
|
},
|
|
},
|
|
},
|
|
});
|
|
return updated;
|
|
},
|
|
},
|
|
}),
|
|
},
|
|
};
|