瀏覽代碼

Replace recursion in status mapStateToProps (#7645)

master
Eugen Rochko 6 年之前
committed by GitHub
父節點
當前提交
dfbadd6837
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 1 個檔案被更改,包括 9 行新增12 行删除
  1. +9
    -12
      app/javascript/mastodon/features/status/index.js

+ 9
- 12
app/javascript/mastodon/features/status/index.js 查看文件

@@ -62,31 +62,28 @@ const makeMapStateToProps = () => {

if (status) {
ancestorsIds = ancestorsIds.withMutations(mutable => {
function addAncestor(id) {
if (id) {
const inReplyTo = state.getIn(['contexts', 'inReplyTos', id]);
let id = status.get('in_reply_to_id');

mutable.unshift(id);
addAncestor(inReplyTo);
}
while (id) {
mutable.unshift(id);
id = state.getIn(['contexts', 'inReplyTos', id]);
}

addAncestor(status.get('in_reply_to_id'));
});

descendantsIds = descendantsIds.withMutations(mutable => {
function addDescendantOf(id) {
const ids = [status.get('id')];

while (ids.length > 0) {
let id = ids.shift();
const replies = state.getIn(['contexts', 'replies', id]);

if (replies) {
replies.forEach(reply => {
mutable.push(reply);
addDescendantOf(reply);
ids.unshift(reply);
});
}
}

addDescendantOf(status.get('id'));
});
}



Loading…
取消
儲存