فهرست منبع

Update token count

- There's a new bug that occurs when you click on any user in the Messages
jblanked 1 سال پیش
والد
کامیت
b0dc8d12ba
7فایلهای تغییر یافته به همراه15 افزوده شده و 52 حذف شده
  1. 0 4
      alloc/flip_social_alloc.c
  2. 0 2
      callback/flip_social_callback.c
  3. 1 1
      explore/flip_social_explore.c
  4. 5 5
      feed/flip_social_feed.c
  5. 0 6
      flip_social.c
  6. 1 5
      flip_social.h
  7. 8 29
      messages/flip_social_messages.c

+ 0 - 4
alloc/flip_social_alloc.c

@@ -181,10 +181,6 @@ FlipSocialApp *flip_social_app_alloc()
     {
         return NULL;
     }
-    if (!easy_flipper_set_buffer(&last_explore_response, app->message_user_choice_logged_in_temp_buffer_size))
-    {
-        return NULL;
-    }
     if (!easy_flipper_set_buffer(&app->explore_logged_in, app->explore_logged_in_temp_buffer_size))
     {
         return NULL;

+ 0 - 2
callback/flip_social_callback.c

@@ -481,7 +481,6 @@ uint32_t flip_social_callback_to_explore_logged_in(void *context)
 {
     UNUSED(context);
     flip_social_dialog_stop = false;
-    last_explore_response = "";
     flip_social_dialog_shown = false;
     if (flip_social_explore)
     {
@@ -499,7 +498,6 @@ uint32_t flip_social_callback_to_friends_logged_in(void *context)
 {
     UNUSED(context);
     flip_social_dialog_stop = false;
-    last_explore_response = "";
     flip_social_dialog_shown = false;
     flip_social_friends->index = 0;
     return FlipSocialViewLoggedInFriendsSubmenu;

+ 1 - 1
explore/flip_social_explore.c

@@ -150,7 +150,7 @@ bool flip_social_parse_json_explore()
     // Parse the JSON array of usernames
     for (size_t i = 0; i < MAX_EXPLORE_USERS; i++)
     {
-        char *username = get_json_array_value("users", i, data_cstr, MAX_TOKENS); // currently its 330 tokens
+        char *username = get_json_array_value("users", i, data_cstr, 64); // currently its 53 tokens (with max explore users at 50)
         if (username == NULL)
         {
             break;

+ 5 - 5
feed/flip_social_feed.c

@@ -167,11 +167,11 @@ bool flip_social_load_feed_post(int post_id)
     }
 
     // Extract individual fields from the JSON object
-    char *username = get_json_value("username", data_cstr, 40);
-    char *message = get_json_value("message", data_cstr, 40);
-    char *flipped = get_json_value("flipped", data_cstr, 40);
-    char *flips = get_json_value("flip_count", data_cstr, 40);
-    char *id = get_json_value("id", data_cstr, 40);
+    char *username = get_json_value("username", data_cstr, 16);
+    char *message = get_json_value("message", data_cstr, 16);
+    char *flipped = get_json_value("flipped", data_cstr, 16);
+    char *flips = get_json_value("flip_count", data_cstr, 16);
+    char *id = get_json_value("id", data_cstr, 16);
 
     if (username == NULL || message == NULL || flipped == NULL || id == NULL)
     {

+ 0 - 6
flip_social.c

@@ -15,7 +15,6 @@ bool flip_social_register_success = false;
 bool flip_social_dialog_shown = false;
 bool flip_social_dialog_stop = false;
 bool flip_social_send_message = false;
-char *last_explore_response = NULL;
 char *selected_message = NULL;
 
 char auth_headers[256] = {0};
@@ -260,16 +259,11 @@ void flip_social_app_free(FlipSocialApp *app)
         free(app->message_user_choice_logged_in);
     if (app->message_user_choice_logged_in_temp_buffer)
         free(app->message_user_choice_logged_in_temp_buffer);
-    if (last_explore_response)
-        free(last_explore_response);
     if (selected_message)
         free(selected_message);
     if (app->explore_user_bio)
         free(app->explore_user_bio);
 
-    if (app->input_event && app->input_event_queue)
-        furi_pubsub_unsubscribe(app->input_event_queue, app->input_event);
-
     // DeInit UART
     flipper_http_deinit();
 

+ 1 - 5
flip_social.h

@@ -17,7 +17,7 @@
 #define MAX_TOKENS 640            // Adjust based on expected JSON tokens
 #define MAX_FEED_ITEMS 50         // Maximum number of feed items
 #define MAX_LINE_LENGTH 30
-#define MAX_MESSAGE_USERS 20 // Maximum number of users to display in the submenu
+#define MAX_MESSAGE_USERS 40 // Maximum number of users to display in the submenu
 #define MAX_MESSAGES 20      // Maximum number of meesages between each user
 
 #define SETTINGS_PATH STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/settings.bin"
@@ -224,9 +224,6 @@ typedef struct
     //
     VariableItem *variable_item_logged_in_profile_friends; // Reference to the friends configuration item
     //
-    FuriPubSub *input_event_queue;
-    FuriPubSubSubscription *input_event;
-
     PreSavedPlaylist pre_saved_messages; // Pre-saved messages for the feed screen
 
     char *is_logged_in;         // Store the login status
@@ -329,7 +326,6 @@ extern bool flip_social_register_success;
 extern bool flip_social_dialog_shown;
 extern bool flip_social_dialog_stop;
 extern bool flip_social_send_message;
-extern char *last_explore_response;
 extern char *selected_message;
 extern char auth_headers[256];
 

+ 8 - 29
messages/flip_social_messages.c

@@ -154,7 +154,7 @@ bool flip_social_get_message_users()
 
     fhttp.save_received_data = true;
     auth_headers_alloc();
-    snprintf(command, 128, "https://www.flipsocial.net/api/messages/%s/get/list/", app_instance->login_username_logged_out);
+    snprintf(command, 128, "https://www.flipsocial.net/api/messages/%s/get/list/%d/", app_instance->login_username_logged_out, MAX_MESSAGE_USERS);
     if (!flipper_http_get_request_with_headers(command, auth_headers))
     {
         FURI_LOG_E(TAG, "Failed to send HTTP request for messages");
@@ -183,7 +183,7 @@ bool flip_social_get_messages_with_user()
         FURI_LOG_E(TAG, "Username is NULL");
         return false;
     }
-    char command[128];
+    char command[256];
     snprintf(
         fhttp.file_path,
         sizeof(fhttp.file_path),
@@ -192,7 +192,7 @@ bool flip_social_get_messages_with_user()
 
     fhttp.save_received_data = true;
     auth_headers_alloc();
-    snprintf(command, 128, "https://www.flipsocial.net/api/messages/%s/get/%s/", app_instance->login_username_logged_out, flip_social_message_users->usernames[flip_social_message_users->index]);
+    snprintf(command, sizeof(command), "https://www.flipsocial.net/api/messages/%s/get/%s/%d/", app_instance->login_username_logged_out, flip_social_message_users->usernames[flip_social_message_users->index], MAX_MESSAGES);
     if (!flipper_http_get_request_with_headers(command, auth_headers))
     {
         FURI_LOG_E(TAG, "Failed to send HTTP request for messages");
@@ -231,18 +231,11 @@ bool flip_social_parse_json_message_users()
         return false;
     }
 
-    // Remove newlines
-    char *pos = data_cstr;
-    while ((pos = strchr(pos, '\n')) != NULL)
-    {
-        *pos = ' ';
-    }
-
     // Initialize message users count
     flip_social_message_users->count = 0;
 
     // Extract the users array from the JSON
-    char *json_users = get_json_value("users", data_cstr, MAX_TOKENS);
+    char *json_users = get_json_value("users", data_cstr, 64);
     if (json_users == NULL)
     {
         FURI_LOG_E(TAG, "Failed to parse users array.");
@@ -324,18 +317,11 @@ bool flip_social_parse_json_message_user_choices()
         return false;
     }
 
-    // Remove newlines
-    char *pos = data_cstr;
-    while ((pos = strchr(pos, '\n')) != NULL)
-    {
-        *pos = ' ';
-    }
-
     // Initialize explore count
     flip_social_explore->count = 0;
 
     // Extract the users array from the JSON
-    char *json_users = get_json_value("users", data_cstr, MAX_TOKENS);
+    char *json_users = get_json_value("users", data_cstr, 64);
     if (json_users == NULL)
     {
         FURI_LOG_E(TAG, "Failed to parse users array.");
@@ -417,13 +403,6 @@ bool flip_social_parse_json_messages()
         return false;
     }
 
-    // Remove newlines
-    char *pos = data_cstr;
-    while ((pos = strchr(pos, '\n')) != NULL)
-    {
-        *pos = ' ';
-    }
-
     // Initialize messages count
     flip_social_messages->count = 0;
 
@@ -431,15 +410,15 @@ bool flip_social_parse_json_messages()
     for (int i = 0; i < MAX_MESSAGES; i++)
     {
         // Parse each item in the array
-        char *item = get_json_array_value("conversations", i, data_cstr, MAX_TOKENS);
+        char *item = get_json_array_value("conversations", i, data_cstr, 128);
         if (item == NULL)
         {
             break;
         }
 
         // Extract individual fields from the JSON object
-        char *sender = get_json_value("sender", item, 64);
-        char *content = get_json_value("content", item, 64);
+        char *sender = get_json_value("sender", item, 32);
+        char *content = get_json_value("content", item, 32);
 
         if (sender == NULL || content == NULL)
         {