Skip to content

Commit

Permalink
Allow Firestore ArrayValue to add the same value type
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Jun 26, 2024
1 parent 04f104c commit 16ef947
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/mobizt/FirebaseClient/.github%2Fworkflows%2Fcompile_library.yml?logo=github&label=compile) [![Github Stars](https://img.shields.io/github/stars/mobizt/FirebaseClient?logo=github)](https://github.com/mobizt/FirebaseClient/stargazers) ![Github Issues](https://img.shields.io/github/issues/mobizt/FirebaseClient?logo=github)

![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.2.18-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)
![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.2.19-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)

[![GitHub Sponsors](https://img.shields.io/github/sponsors/mobizt?logo=github)](https://github.com/sponsors/mobizt)

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FirebaseClient",
"version": "1.2.18",
"version": "1.2.19",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "Async Firebase Client library for Arduino.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=FirebaseClient

version=1.2.18
version=1.2.19

author=Mobizt

Expand Down
2 changes: 1 addition & 1 deletion src/core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#undef FIREBASE_CLIENT_VERSION
#endif

#define FIREBASE_CLIENT_VERSION "1.2.18"
#define FIREBASE_CLIENT_VERSION "1.2.19"

static void sys_idle()
{
Expand Down
33 changes: 6 additions & 27 deletions src/firestore/Values.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Created June 22, 2024
* Created June 26, 2024
*
* The MIT License (MIT)
* Copyright (c) 2024 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -328,27 +328,9 @@ namespace Values
ObjectWriter owriter;
bool flags[11];

template <typename T>
bool isExisted(T value)
{
String tmp = value.val();
for (size_t i = 0; i <= firestore_const_key_mapValue; i++)
{
if (tmp.indexOf(firestore_const_key[i].text) > -1)
{
if (flags[i])
return true;
flags[i] = 1;
}
}

return false;
}
template <typename T>
void set(T value)
{
if (isExisted(value))
return;
owriter.setPair(buf, FPSTR("values"), value.val(), true);
}

Expand All @@ -375,14 +357,11 @@ namespace Values
template <typename T>
ArrayValue &add(T value)
{
if (!isExisted(value))
{
if (buf.length() == 0)
set(value);
else
owriter.addMember(buf, value.val(), false, "]}");
getVal();
}
if (buf.length() == 0)
set(value);
else
owriter.addMember(buf, value.val(), false, "]}");
getVal();
return *this;
}
const char *c_str() const { return buf.c_str(); }
Expand Down

0 comments on commit 16ef947

Please sign in to comment.