mirror of
https://github.com/wassname/talk.git
synced 2026-06-30 06:47:33 +08:00
44 lines
1.3 KiB
JavaScript
44 lines
1.3 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;
|
|
}
|
|
}
|
|
}),
|
|
},
|
|
};
|