diff --git a/src/LBackend.h b/src/LBackend.h index f75995299..5adcafabe 100644 --- a/src/LBackend.h +++ b/src/LBackend.h @@ -31,6 +31,7 @@ void LBackend_UpdateTitleFont(void); void LBackend_DrawTitle(struct Context2D* ctx, const char* title); void LBackend_DecodeFlag(struct Flag* flag, cc_uint8* data, cc_uint32 len); +void LBackend_TableFlagAdded(struct LTable* w); /* Marks the entire launcher contents as needing to be redrawn */ void LBackend_Redraw(void); diff --git a/src/LBackend_ios.m b/src/LBackend_ios.m index 524b731e7..0cb0ba8b6 100644 --- a/src/LBackend_ios.m +++ b/src/LBackend_ios.m @@ -598,19 +598,14 @@ static void LTable_UpdateCell(UITableView* table, UITableViewCell* cell, int row } // TODO only redraw flags -static void OnFlagsChanged(void) { - struct LScreen* s = Launcher_Active; - for (int i = 0; i < s->numWidgets; i++) - { - if (s->widgets[i]->type != LWIDGET_TABLE) continue; - UITableView* tbl = (__bridge UITableView*)s->widgets[i]->meta; - - // trying to update cell.imageView.image doesn't seem to work, - // so pointlessly reload entire table data instead - NSIndexPath* selected = [tbl indexPathForSelectedRow]; - [tbl reloadData]; - [tbl selectRowAtIndexPath:selected animated:NO scrollPosition:UITableViewScrollPositionNone]; - } +void LBackend_TableFlagAdded(struct LTable* w) { + UITableView* tbl = (__bridge UITableView*)w->meta; + + // trying to update cell.imageView.image doesn't seem to work, + // so pointlessly reload entire table data instead + NSIndexPath* selected = [tbl indexPathForSelectedRow]; + [tbl reloadData]; + [tbl selectRowAtIndexPath:selected animated:NO scrollPosition:UITableViewScrollPositionNone]; } /*########################################################################################################################* @@ -621,8 +616,7 @@ void LBackend_DecodeFlag(struct Flag* flag, cc_uint8* data, cc_uint32 len) { UIImage* img = [UIImage imageWithData:ns_data]; if (!img) return; - flag->meta = CFBridgingRetain(img); - OnFlagsChanged(); + flag->meta = CFBridgingRetain(img); } static void LBackend_LayoutDimensions(struct LWidget* w, CGRect* r) { diff --git a/src/LScreens.c b/src/LScreens.c index fe022d566..d963dafe6 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -1347,9 +1347,8 @@ static void ServersScreen_Tick(struct LScreen* s_) { flagsCount = FetchFlagsTask.count; LWebTask_Tick(&FetchFlagsTask.Base, NULL); - if (flagsCount != FetchFlagsTask.count) { - LBackend_NeedsRedraw(&s->table); + LBackend_TableFlagAdded(&s->table); } if (!FetchServersTask.Base.working) return;