fix: do not mirror post when posting with groups (#101)

This commit is contained in:
tsukino
2023-03-22 16:30:52 +08:00
committed by GitHub
parent bedede1954
commit caa6179d26
3 changed files with 27 additions and 2 deletions

View File

@@ -45,18 +45,19 @@
"draft-js": "^0.11.7",
"draft-js-table": "^0.3.0",
"elliptic": "^6.5.4",
"eth-json-rpc-middleware": "git+https://github.com/zkitter/eth-json-rpc-middleware.git#6.0.0-a",
"ethereum-blockies-base64": "^1.0.2",
"ethers": "^5.7.2",
"eventemitter2": "^6.4.9",
"fast-deep-equal": "^3.1.3",
"gun": "0.2020.1232",
"isomorphic-fetch": "^3.0.0",
"eth-json-rpc-middleware": "git+https://github.com/zkitter/eth-json-rpc-middleware.git#6.0.0-a",
"lodash.debounce": "^4.0.8",
"magnet-uri": "^6.2.0",
"markdown-draft-js": "^2.4.0",
"mime-types": "^2.1.35",
"moment": "^2.29.4",
"node-fetch": "^2.6.9",
"pretty-bytes": "^6.0.0",
"react": "~16",
"react-dom": "~16",

View File

@@ -1,6 +1,8 @@
import { ducks, fetchReset, fetchStub, store } from '~/testUtils';
import { createEditorStateWithText } from '@draft-js-plugins/editor';
import { ZkIdentity } from '@zk-kit/identity';
import { setPostingGroup } from '@ducks/worker';
import { PostMessageSubType } from '~/message';
const {
setMirror,
@@ -49,6 +51,28 @@ describe('Drafts Duck', () => {
method: 'POST',
},
]);
fetchReset();
});
it('should not mirror post when submitting group post', async () => {
store.dispatch(
setDraft({
reference: '',
editorState: createEditorStateWithText('hello world!'),
})
);
store.dispatch(setMirror(true));
store.dispatch(setPostingGroup('zksocial_all'));
// @ts-ignore
const post: any = await store.dispatch(submitPost(''));
expect(post.payload).toStrictEqual({
attachment: '',
content: 'hello world!',
reference: '',
title: '',
topic: 'ok',
});
expect(post.subtype).not.toStrictEqual(PostMessageSubType.MirrorPost);
});
// FIXME ENOENT: no such file or directory, open 'http://127.0.0.1:3000/circuits/rln/wasm'

View File

@@ -474,7 +474,7 @@ export const submitPost =
let replyToTweetId;
let replyToUsername;
if (shouldMirror) {
if (selected?.type === 'gun' && !postingGroup && shouldMirror) {
subtype = reference ? PostMessageSubType.MirrorReply : PostMessageSubType.MirrorPost;
if (