Skip to content

[INVESTIGATION] Impact of the finding that rem.getCards() does not return cards that are disabled (or paused) #176

@hugomarins

Description

@hugomarins

RemNote developers informed that rem.getCards() does not return cards that are disabled (or paused).

This may be the reason why empty arrays [] were being returned for valid flashcard rems.

The current command can be used in the console to check if the cards of the currently focused rem are being gathered by rem.getCards() or if any inconsistency is found:

(async () => {
    // 1. Get the focused Rem
    const rem = await __plugin.focus.getFocusedRem();
    if (!rem) { 
        console.error("❌ No Rem focused. Please click on the bullet of the broken Flashcard."); 
        return; 
    }

    console.group(`🐞 API Inconsistency Report for Rem ID: ${rem._id}`);
    console.log("Rem Text:", (await rem.text)[0]);

    // TEST A: Local Object Method (The one returning [])
    const startA = performance.now();
    const localCards = await rem.getCards();
    const timeA = performance.now() - startA;
    
    // TEST B: Global Registry Method (The one working correctly)
    const startB = performance.now();
    const allCards = await __plugin.card.getAll();
    const globalCards = allCards.filter(c => c.remId === rem._id);
    const timeB = performance.now() - startB;

    // REPORT
    console.log(`[A] rem.getCards(): Found ${localCards.length} cards (${timeA.toFixed(1)}ms)`);
    console.dir(localCards);

    console.log(`[B] plugin.card.getAll() [Filtered]: Found ${globalCards.length} cards (${timeB.toFixed(1)}ms)`);
    console.dir(globalCards);

    if (localCards.length === 0 && globalCards.length > 0) {
        console.error("%c🚨 INCONSISTENCY CONFIRMED 🚨", "color: red; font-size: 14px; font-weight: bold;");
        console.error("The Global Registry sees the card, but the specific Rem object does not return it.");
        console.log("Expected: rem.getCards() should match the global registry.");
    } else {
        console.log("✅ No inconsistency detected on this specific Rem.");
    }
    
    console.groupEnd();
})();

As the plugin runs in an iframe, make sure the console context is set to your plugin's iframe (the command must be inserted when an index.html iframe console context is selected).

We need to ponder, in light of this new information, if the changes made in v. 0.2.46 (#170 ) must be reviewed, and if there is a cheaper way to find out if a rem has flashcards in its descendants (for instance, for the priority popup checks).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions