Bug 443972

Summary: 'Recent' emojis tab can't be accessed until after restart
Product: [Plasma] plasmashell Reporter: Gabriel <gabriel>
Component: Emoji SelectorAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: minor CC: nate
Priority: NOR    
Version: 5.23.0   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.24

Description Gabriel 2021-10-18 12:36:55 UTC
SUMMARY
When opening the emoji selector with no history, the 'Recent' tab will be inaccessible despite clicking emojis – until closing and reopening the selector.

STEPS TO REPRODUCE
1. Open the emoji selector with no history
2. Click some emojis
3. Try to access the 'Recent' tab

OBSERVED RESULT
The tab is still greyed out and can't be clicked

EXPECTED RESULT
As soon as there is history to display, you can access 'Recent'

SOFTWARE
OS: KDE neon 5.23
KDE Plasma Version: 5.23.0
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.3
Comment 1 Nate Graham 2021-10-18 17:51:29 UTC
It has this:

enabled: recentEmojiModel.count > 0

Which means recentEmojiModel isn't getting updated immediately after something is added to or removed from it.
Comment 2 Nate Graham 2021-10-18 17:51:51 UTC
I see that the config file is updated immediately though.
Comment 3 Nate Graham 2021-10-18 18:00:12 UTC
Basically `count` on the QML side isn't getting notifications of changes made on the C++ side.
Comment 4 Nate Graham 2021-10-18 18:08:05 UTC
Oh I see, `count` isn't actually a property at all and we're implicitly invoking it as a function. That explains it.
Comment 5 Nate Graham 2021-10-18 18:45:46 UTC
Giving up for now, too annoying
Comment 6 Gabriel 2021-10-18 18:58:29 UTC
Sounds very strange from what you're explaining. Either way, I appreciate the updates here, that give a sense of what's going on. It really makes reporting and triaging bugs quite enjoyable. Thanks for the good work!
Comment 7 Nate Graham 2021-10-19 13:33:16 UTC
You're welcome!

In a nutshell, the app enables and disables the recents entry based on there being at least one emoji in the "recent emojis model" backend code, but it only checks once, when the app is launched. It doesn't know how to monitor that value in real-time as it's updated based on user action.

So as you the user use emojis, they get added to the "recent emojis model" in real time, which syncs them to the config file in real time, but the number of emojis in it isn't sent to the sidebar code, so as far as it's concerned, the number of recent emojis remains what it was when it first checked at launch.

This would probably be trivial to fix for someone smarter than me.
Comment 8 Gabriel 2021-10-19 14:32:13 UTC
I hope it's not blasphemy to ask, but does it actually need to be disabled when empty? Couldn't there simply be some text saying "No recent history"?

I do see the value in not starting on that entry if there is nothing to show, but maybe that can be done without having to disable it. Essentially: if recentEmojiModel.count > 0, start on the recents entry, otherwise, start on the first normal entry.

I admit that I don't have a good understanding of how the code here works. I'm just assuming that specifying which entry to start on is simpler than getting enable/disable to work properly.
Comment 9 Nate Graham 2021-10-19 14:46:44 UTC
lol that would work too
Comment 10 Nate Graham 2021-10-19 14:53:48 UTC
Brilliant bit of out-of-the-box thinking. I'll do that. Thanks a lot!
Comment 11 Bug Janitor Service 2021-10-19 15:00:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/611
Comment 12 Gabriel 2021-10-19 15:15:11 UTC
Wow that was quick! :^D
Comment 13 Nate Graham 2021-10-19 15:15:43 UTC
I already had the files open. :)
Comment 14 Nate Graham 2021-10-19 17:49:25 UTC
Git commit f78bd646d225580cff136e5fe648e897f31c4279 by Nate Graham.
Committed on 19/10/2021 at 17:48.
Pushed by ngraham into branch 'master'.

emojier: Show placeholder message instead of disabling recents when empty

Right now we disable the recents view when it's empty, but this relies
on querying recentEmojiModel.count, which is not a property, so it
doesn't update as the model fills up with recents. Making it a property
is annoying, and a better UX is simply to show a placeholder message on
the page when it's empty as we do in other places. The code already
skips showing the view on launch if it's empty, so everything still
works.
FIXED-IN: 5.24

M  +8    -1    applets/kimpanel/backend/ibus/emojier/app/ui/CategoryPage.qml
M  +0    -1    applets/kimpanel/backend/ibus/emojier/app/ui/emojier.qml

https://invent.kde.org/plasma/plasma-desktop/commit/f78bd646d225580cff136e5fe648e897f31c4279