Skip to content

Commit

Permalink
load on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
halfmexican committed Sep 13, 2024
1 parent a2441d0 commit 22ee9f4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
20 changes: 15 additions & 5 deletions src/emoji_data_manager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,21 @@ namespace Mingle {
return combinations_map;
}

public EmojiData ? get_emoji_data (string emoji_codepoint) {
if (!emoji_data_map.has_key (emoji_codepoint)) {
emoji_data_map[emoji_codepoint] = create_emoji_data (emoji_codepoint);
public EmojiData? get_emoji_data(string emoji_codepoint) {
if (!emoji_data_map.has_key(emoji_codepoint)) {
emoji_data_map[emoji_codepoint] = create_emoji_data(emoji_codepoint);
}
return emoji_data_map[emoji_codepoint];

EmojiData? emoji_data = emoji_data_map[emoji_codepoint];
if (emoji_data != null && emoji_data.combinations == null) {
Json.Object data_object = root_object.get_object_member("data");
Json.Object? emoji_object = data_object.get_object_member(emoji_codepoint);
if (emoji_object != null) {
emoji_data.combinations = populate_combinations(emoji_object.get_object_member("combinations"));
}
}

return emoji_data;
}

private EmojiData ? create_emoji_data (string emoji_codepoint) {
Expand All @@ -203,7 +213,7 @@ namespace Mingle {
emoji_data.keywords = emoji_object.get_array_member ("keywords");
emoji_data.emoji_codepoint = emoji_codepoint;
emoji_data.gboard_order = (int) emoji_object.get_int_member ("gBoardOrder");
emoji_data.combinations = populate_combinations (emoji_object.get_object_member ("combinations"));
emoji_data.combinations = null; // Initialize combinations to null

return emoji_data;
}
Expand Down
2 changes: 1 addition & 1 deletion src/emoji_structs.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Mingle {
public Json.Array keywords;
public string emoji_codepoint;
public int gboard_order;
public Gee.HashMap<string, Gee.List<EmojiCombination?>> combinations;
public Gee.HashMap<string, Gee.List<EmojiCombination?>>? combinations;
}

public struct EmojiCombination {
Expand Down
2 changes: 2 additions & 0 deletions src/window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ namespace Mingle {
this.set_title (title);
}



// Toolbar Style
private void apply_toolbar_style () {
var style = get_toolbar_style ();
Expand Down

0 comments on commit 22ee9f4

Please sign in to comment.