mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor: use post number instead of shortCid in reply modal and quote previews
This commit is contained in:
@@ -4,16 +4,18 @@ import useSelectedTextStore from './use-selected-text-store';
|
||||
interface ReplyModalState {
|
||||
showReplyModal: boolean;
|
||||
activeCid: string | null;
|
||||
parentNumber: number | null;
|
||||
threadCid: string | null;
|
||||
subplebbitAddress: string | null;
|
||||
scrollY: number;
|
||||
closeModal: () => void;
|
||||
openReplyModal: (parentCid: string, postCid: string, subplebbitAddress: string) => void;
|
||||
openReplyModal: (parentCid: string, parentNumber: number | undefined, postCid: string, subplebbitAddress: string) => void;
|
||||
}
|
||||
|
||||
const useReplyModalStore = create<ReplyModalState>((set, get) => ({
|
||||
showReplyModal: false,
|
||||
activeCid: null,
|
||||
parentNumber: null,
|
||||
threadCid: null,
|
||||
subplebbitAddress: null,
|
||||
scrollY: 0,
|
||||
@@ -24,10 +26,11 @@ const useReplyModalStore = create<ReplyModalState>((set, get) => ({
|
||||
set({
|
||||
showReplyModal: false,
|
||||
activeCid: null,
|
||||
parentNumber: null,
|
||||
});
|
||||
},
|
||||
|
||||
openReplyModal: (parentCid, postCid, subplebbitAddress) => {
|
||||
openReplyModal: (parentCid, parentNumber, postCid, subplebbitAddress) => {
|
||||
// Don't update if already open with different parent
|
||||
if (get().activeCid && get().activeCid !== parentCid) {
|
||||
window.alert('Multiple quotes are not possible on 5chan for the time being, because of a protocol limitation. Please reply to one post at a time.');
|
||||
@@ -46,6 +49,7 @@ const useReplyModalStore = create<ReplyModalState>((set, get) => ({
|
||||
|
||||
set({
|
||||
activeCid: parentCid,
|
||||
parentNumber: parentNumber ?? null,
|
||||
threadCid: postCid,
|
||||
showReplyModal: true,
|
||||
subplebbitAddress,
|
||||
|
||||
Reference in New Issue
Block a user