AminoJS / Amino.JS

A powerful JavaScript library for interacting with the Amino API :star2:
MIT License
27 stars 5 forks source link

Arraystacking in getChat Function #34

Closed moelrobi closed 6 years ago

moelrobi commented 6 years ago

Describe the bug The Array when getChat is Called is stacking / filling up without any clearing. So with every call the Array Fills up.

To Reproduce Steps to reproduce the behavior:

//This Snippet shows the Bug in action!
    let chats = await Amino.getJoinedChats(community);
    chats.threads.forEach(async (el) => {
        let chat = await Amino.getChat(community, el.threadId);
        console.log(chat);
    })

Expected behavior It should return one Messages Array per Call and clear it right after, instead it filles the Array endllessly.

Desktop (please complete the following information):

felixfong227 commented 6 years ago

Can we like start the cleaning job once the array index reached 100(further discuss), and maybe add a new child method for getChat() for keep tracking how many object is inside the array and a method for the actual cleaning job

Examples

const chats = await Amino.getJoinedChats(community);
chats.threads.forEach(async (el) => {
    const chat = await Amino.getChat(community, el.threadId);
    const howMany = await chat.stacks(); // #=> 10
    // If the stacks is over 20, then clean it up plz
    if(howMany >= 20){
        await chat.cleanUpStacks();
    }
});
moelrobi commented 6 years ago

Getting fixed in #39

Closed!