fix(ui-new): one '#' on a hashtag channel's favourite tile and slot list

Hashtag channel names already start with '#'; the tiles added another
("##test"). chanctl::bareName() is now the one place that strips it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-08 23:41:40 +02:00
co-authored by Claude Opus 5.5
parent 9ef7d5d981
commit 92e379e05c
3 changed files with 7 additions and 3 deletions
@@ -19,6 +19,10 @@ namespace chanctl {
enum Result : uint8_t { OK, FULL, NO_NAME, NO_SECRET, BAD_SECRET, EXISTS, FAILED }; enum Result : uint8_t { OK, FULL, NO_NAME, NO_SECRET, BAD_SECRET, EXISTS, FAILED };
// A channel's name without the '#' a hashtag channel's starts with -- for a
// label that puts its own '#' in front (as ui-new's tiles do), never "##test".
static inline const char* bareName(const char* name) { return name[0] == '#' ? name + 1 : name; }
static const char* resultText(Result r) { static const char* resultText(Result r) {
switch (r) { switch (r) {
case OK: return "Saved"; case OK: return "Saved";
@@ -721,7 +721,7 @@ class MessagesScreen : public UIScreen {
ChannelDetails ch; ChannelDetails ch;
if (the_mesh.getChannel(pfx[0], ch) && ch.name[0]) { if (the_mesh.getChannel(pfx[0], ch) && ch.name[0]) {
nm[0] = '#'; nm[0] = '#';
DisplayDriver::translateUTF8Static(nm + 1, ch.name, sizeof(nm) - 1); DisplayDriver::translateUTF8Static(nm + 1, chanctl::bareName(ch.name), sizeof(nm) - 1);
} }
} else { } else {
for (int idx = 0; ; idx++) { for (int idx = 0; ; idx++) {
+2 -2
View File
@@ -463,7 +463,7 @@ class HomeScreen : public UIScreen {
ChannelDetails cd; ChannelDetails cd;
if (!the_mesh.getChannel(c[k].ch, cd) || !cd.name[0]) continue; if (!the_mesh.getChannel(c[k].ch, cd) || !cd.name[0]) continue;
r.ch = c[k].ch; r.ch = c[k].ch;
snprintf(r.name, sizeof(r.name), "#%s", cd.name[0] == '#' ? cd.name + 1 : cd.name); snprintf(r.name, sizeof(r.name), "#%s", chanctl::bareName(cd.name));
r.n = _task->getChannelUnread(r.ch); r.n = _task->getChannelUnread(r.ch);
r.overflow = r.n > 0 && _task->getChannelUnreadOverflow(r.ch); r.overflow = r.n > 0 && _task->getChannelUnreadOverflow(r.ch);
} else { } else {
@@ -1645,7 +1645,7 @@ public:
// '#' marks a channel apart from a contact tile — the two share the // '#' marks a channel apart from a contact tile — the two share the
// grid and Enter does something different on each. // grid and Enter does something different on each.
name[0] = '#'; name[0] = '#';
display.translateUTF8ToBlocks(name + 1, ch.name, sizeof(name) - 1); display.translateUTF8ToBlocks(name + 1, chanctl::bareName(ch.name), sizeof(name) - 1);
unread = _task->getChannelUnread(ch_idx); unread = _task->getChannelUnread(ch_idx);
overflow = unread > 0 && _task->getChannelUnreadOverflow(ch_idx); overflow = unread > 0 && _task->getChannelUnreadOverflow(ch_idx);
resolved = true; resolved = true;