Simplify table updating when a flag is downloaded

This commit is contained in:
UnknownShadow200 2024-10-03 21:25:08 +10:00
parent 10f849cad1
commit 447d4060d5
3 changed files with 11 additions and 17 deletions

View file

@ -31,6 +31,7 @@ void LBackend_UpdateTitleFont(void);
void LBackend_DrawTitle(struct Context2D* ctx, const char* title); void LBackend_DrawTitle(struct Context2D* ctx, const char* title);
void LBackend_DecodeFlag(struct Flag* flag, cc_uint8* data, cc_uint32 len); 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 */ /* Marks the entire launcher contents as needing to be redrawn */
void LBackend_Redraw(void); void LBackend_Redraw(void);

View file

@ -598,19 +598,14 @@ static void LTable_UpdateCell(UITableView* table, UITableViewCell* cell, int row
} }
// TODO only redraw flags // TODO only redraw flags
static void OnFlagsChanged(void) { void LBackend_TableFlagAdded(struct LTable* w) {
struct LScreen* s = Launcher_Active; UITableView* tbl = (__bridge UITableView*)w->meta;
for (int i = 0; i < s->numWidgets; i++)
{ // trying to update cell.imageView.image doesn't seem to work,
if (s->widgets[i]->type != LWIDGET_TABLE) continue; // so pointlessly reload entire table data instead
UITableView* tbl = (__bridge UITableView*)s->widgets[i]->meta; NSIndexPath* selected = [tbl indexPathForSelectedRow];
[tbl reloadData];
// trying to update cell.imageView.image doesn't seem to work, [tbl selectRowAtIndexPath:selected animated:NO scrollPosition:UITableViewScrollPositionNone];
// 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]; UIImage* img = [UIImage imageWithData:ns_data];
if (!img) return; if (!img) return;
flag->meta = CFBridgingRetain(img); flag->meta = CFBridgingRetain(img);
OnFlagsChanged();
} }
static void LBackend_LayoutDimensions(struct LWidget* w, CGRect* r) { static void LBackend_LayoutDimensions(struct LWidget* w, CGRect* r) {

View file

@ -1347,9 +1347,8 @@ static void ServersScreen_Tick(struct LScreen* s_) {
flagsCount = FetchFlagsTask.count; flagsCount = FetchFlagsTask.count;
LWebTask_Tick(&FetchFlagsTask.Base, NULL); LWebTask_Tick(&FetchFlagsTask.Base, NULL);
if (flagsCount != FetchFlagsTask.count) { if (flagsCount != FetchFlagsTask.count) {
LBackend_NeedsRedraw(&s->table); LBackend_TableFlagAdded(&s->table);
} }
if (!FetchServersTask.Base.working) return; if (!FetchServersTask.Base.working) return;