Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2. Add ability to force refresh a particular card #180

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/ESPDash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void ESPDash::remove(Statistic *statistic) {
}

// generates the layout JSON string to the frontend
size_t ESPDash::generateLayoutJSON(AsyncWebSocketClient *client, bool changes_only) {
size_t ESPDash::generateLayoutJSON(AsyncWebSocketClient *client, bool changes_only, Card *onlyCard) {
String buf = "";
buf.reserve(DASH_LAYOUT_JSON_SIZE);

Expand All @@ -183,7 +183,7 @@ size_t ESPDash::generateLayoutJSON(AsyncWebSocketClient *client, bool changes_on
if (changes_only) {
if (c->_changed) {
c->_changed = false;
} else {
} else if (onlyCard == nullptr || onlyCard->_id != c->_id) {
continue;
}
}
Expand Down Expand Up @@ -461,6 +461,10 @@ void ESPDash::refreshStatistics() {
generateLayoutJSON(nullptr, true);
}

void ESPDash::refreshCard(Card *card) {
generateLayoutJSON(nullptr, true, card);
}


/*
Destructor
Expand Down
3 changes: 2 additions & 1 deletion src/ESPDash.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ESPDash{
char password[64];

// Generate layout json
size_t generateLayoutJSON(AsyncWebSocketClient *client, bool changes_only = false);
size_t generateLayoutJSON(AsyncWebSocketClient *client, bool changes_only = false, Card *onlyCard = nullptr);

// Generate Component JSON
void generateComponentJSON(JsonObject& obj, Card* card, bool change_only = false);
Expand Down Expand Up @@ -117,6 +117,7 @@ class ESPDash{
void sendUpdates(bool force = false);

void refreshStatistics();
void refreshCard(Card *card);

~ESPDash();
};
Expand Down
Loading