diff options
author | fiaxh <git@lightrise.org> | 2023-01-29 23:06:01 +0100 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2023-01-30 22:54:55 +0100 |
commit | b0b81b88c6948dcfd2b1b82a9fe7357316a3af1f (patch) | |
tree | ea44aed7431b955ef8b1636f74c8ebe42bacb099 /libdino/src/service/entity_info.vala | |
parent | 10a2bce5122dcd1e6fef037633a26568bf27d4d1 (diff) | |
download | dino-b0b81b88c6948dcfd2b1b82a9fe7357316a3af1f.tar.gz dino-b0b81b88c6948dcfd2b1b82a9fe7357316a3af1f.zip |
Always display reaction+reply buttons, disable if not possible
Diffstat (limited to 'libdino/src/service/entity_info.vala')
-rw-r--r-- | libdino/src/service/entity_info.vala | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/libdino/src/service/entity_info.vala b/libdino/src/service/entity_info.vala index d7d0bc9e..d1217e81 100644 --- a/libdino/src/service/entity_info.vala +++ b/libdino/src/service/entity_info.vala @@ -79,22 +79,34 @@ public class EntityInfo : StreamInteractionModule, Object { } public async bool has_feature(Account account, Jid jid, string feature) { + int has_feature_cached = has_feature_cached_int(account, jid, feature); + if (has_feature_cached != -1) { + return has_feature_cached == 1; + } + + ServiceDiscovery.InfoResult? info_result = yield get_info_result(account, jid, entity_caps_hashes[jid]); + if (info_result == null) return false; + + return info_result.features.contains(feature); + } + + public bool has_feature_cached(Account account, Jid jid, string feature) { + return has_feature_cached_int(account, jid, feature) == 1; + } + + private int has_feature_cached_int(Account account, Jid jid, string feature) { if (jid_features.has_key(jid)) { - return jid_features[jid].contains(feature); + return jid_features[jid].contains(feature) ? 1 : 0; } string? hash = entity_caps_hashes[jid]; if (hash != null) { Gee.List<string>? features = get_stored_features(hash); if (features != null) { - return features.contains(feature); + return features.contains(feature) ? 1 : 0; } } - - ServiceDiscovery.InfoResult? info_result = yield get_info_result(account, jid, hash); - if (info_result == null) return false; - - return info_result.features.contains(feature); + return -1; } private void on_received_available_presence(Account account, Presence.Stanza presence) { |