Remove immutable
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
b01d8585ad
commit
0d42eddbf8
5 changed files with 11 additions and 26 deletions
|
@ -66,7 +66,6 @@
|
|||
"graphemesplit": "^2.4.4",
|
||||
"html-react-parser": "^5.1.18",
|
||||
"immer": "^10.1.1",
|
||||
"immutable": "^4.3.7",
|
||||
"intersection-observer": "^0.12.2",
|
||||
"intl-messageformat": "^10.6.0",
|
||||
"intl-pluralrules": "^2.0.1",
|
||||
|
|
|
@ -54,7 +54,7 @@ export const getDescendantsIds = createSelector([
|
|||
}
|
||||
|
||||
if (statusId !== id) {
|
||||
descendantsIds = descendantsIds.union(new Set(id));
|
||||
descendantsIds = descendantsIds.union(new Set([id]));
|
||||
}
|
||||
|
||||
if (replies) {
|
||||
|
@ -90,7 +90,6 @@ const Thread: React.FC<IThread> = ({
|
|||
const showMedia = statusesMeta[status.id]?.visible ?? !status.sensitive;
|
||||
|
||||
const { ancestorsIds, descendantsIds } = useAppSelector((state) => {
|
||||
console.log(state.contexts);
|
||||
let ancestorsIds = new Set<string>();
|
||||
let descendantsIds = new Set<string>();
|
||||
|
||||
|
@ -100,17 +99,17 @@ const Thread: React.FC<IThread> = ({
|
|||
descendantsIds = getDescendantsIds(state, statusId);
|
||||
|
||||
ancestorsIds.delete(statusId);
|
||||
descendantsIds.forEach(ancestorsIds.delete);
|
||||
descendantsIds.forEach(descendantsId => ancestorsIds.delete(descendantsId));
|
||||
descendantsIds.delete(statusId);
|
||||
ancestorsIds.forEach(descendantsIds.delete);
|
||||
ancestorsIds.forEach(ancestorsId => descendantsIds.delete(ancestorsId));
|
||||
}
|
||||
|
||||
return {
|
||||
status,
|
||||
ancestorsIds: Array.from(ancestorsIds),
|
||||
descendantsIds: Array.from(descendantsIds),
|
||||
};
|
||||
});
|
||||
console.log(ancestorsIds, descendantsIds);
|
||||
|
||||
let initialTopMostItemIndex = ancestorsIds.length;
|
||||
if (!useWindowScroll && initialTopMostItemIndex !== 0) initialTopMostItemIndex = ancestorsIds.length + 1;
|
||||
|
@ -306,9 +305,7 @@ const Thread: React.FC<IThread> = ({
|
|||
</p>,
|
||||
);
|
||||
children.push(...renderChildren(descendantsIds));
|
||||
}
|
||||
|
||||
if (hasDescendants) {
|
||||
} else if (hasDescendants) {
|
||||
children.push(...renderChildren(descendantsIds));
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ const StatusDetails: React.FC<IStatusDetails> = (props) => {
|
|||
ancestorsIds = getAncestorsIds(state, state.contexts.inReplyTos[statusId]);
|
||||
descendantsIds = getDescendantsIds(state, statusId);
|
||||
ancestorsIds.delete(statusId);
|
||||
descendantsIds.forEach(ancestorsIds.delete);
|
||||
descendantsIds.forEach((descendantId) => ancestorsIds.delete(descendantId));
|
||||
}
|
||||
|
||||
return Array.from(ancestorsIds);
|
||||
|
|
|
@ -24,7 +24,7 @@ const importStatus = (state: State, status: ContextStatus) => {
|
|||
const { id, in_reply_to_id: inReplyToId } = status;
|
||||
if (!inReplyToId) return;
|
||||
|
||||
const replies = state.replies[inReplyToId];
|
||||
const replies = state.replies[inReplyToId] || [];
|
||||
const newReplies = [...replies, id].toSorted();
|
||||
|
||||
state.replies[inReplyToId] = newReplies;
|
||||
|
@ -54,7 +54,6 @@ const getRootNode = (state: State, statusId: string, initialId = statusId): stri
|
|||
|
||||
/** Route fromId to toId by inserting tombstones. */
|
||||
const connectNodes = (state: State, fromId: string, toId: string) => {
|
||||
console.log(`connecting ${fromId} ${toId}`);
|
||||
const fromRoot = getRootNode(state, fromId);
|
||||
const toRoot = getRootNode(state, toId);
|
||||
|
||||
|
@ -65,13 +64,10 @@ const connectNodes = (state: State, fromId: string, toId: string) => {
|
|||
|
||||
/** Import a branch of ancestors or descendants, in relation to statusId. */
|
||||
const importBranch = (state: State, statuses: ContextStatus[], statusId?: string) => {
|
||||
console.log(`importing branch ${statusId}`);
|
||||
console.log(statuses);
|
||||
statuses.forEach((status, i) => {
|
||||
const prevId = statusId && i === 0 ? statusId : statuses[i - 1]?.id;
|
||||
|
||||
if (status.in_reply_to_id) {
|
||||
console.log(`importing status ${status.id}`);
|
||||
importStatus(state, status);
|
||||
|
||||
// On Mastodon, in_reply_to_id can refer to an unavailable status,
|
||||
|
@ -101,8 +97,6 @@ const normalizeContext = (
|
|||
insertTombstone(state, ancestors[ancestors.length - 1].id, id);
|
||||
}
|
||||
|
||||
console.log(state);
|
||||
|
||||
return state;
|
||||
};
|
||||
|
||||
|
@ -111,10 +105,10 @@ const contexts = (state = initialState, action: StatusesAction | TimelineAction)
|
|||
switch (action.type) {
|
||||
case CONTEXT_FETCH_SUCCESS:
|
||||
return produce(state, draft => normalizeContext(draft, action.statusId, action.ancestors, action.descendants));
|
||||
// case STATUS_IMPORT:
|
||||
// return importStatus(state, action.status, action.idempotencyKey);
|
||||
// case STATUSES_IMPORT:
|
||||
// return importStatuses(state, action.statuses);
|
||||
// case STATUS_IMPORT:
|
||||
// return importStatus(state, action.status, action.idempotencyKey);
|
||||
// case STATUSES_IMPORT:
|
||||
// return importStatuses(state, action.statuses);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -4295,11 +4295,6 @@ immutable@^4.0.0:
|
|||
resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.3.4.tgz#2e07b33837b4bb7662f288c244d1ced1ef65a78f"
|
||||
integrity sha512-fsXeu4J4i6WNWSikpI88v/PcVflZz+6kMhUfIwc5SY+poQRPnaf5V7qds6SUyUN3cVxEzuCab7QIoLOQ+DQ1wA==
|
||||
|
||||
immutable@^4.3.7:
|
||||
version "4.3.7"
|
||||
resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.3.7.tgz#c70145fc90d89fb02021e65c84eb0226e4e5a381"
|
||||
integrity sha512-1hqclzwYwjRDFLjcFxOM5AYkkG0rpFPpr1RLPMEuGczoS7YA8gLhy8SWXYRAA/XwfEHpfo3cw5JGioS32fnMRw==
|
||||
|
||||
import-fresh@^3.2.1, import-fresh@^3.3.0:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
|
||||
|
|
Loading…
Reference in a new issue