revert(reactions): hover bar shows the account default reactions again
- Undo the most used quick reactions from 8104df5, the skin tone save fix stays Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -2,7 +2,6 @@ use gpui_kit::Context;
2
2
3
3
use crate::app_state::AppState;
4
4
use crate::emoticons;
5
use crate::rows::reaction_glyph;
6
5
7
6
pub fn quick_reaction_glyphs(reaction_ids: &[String], skin_tone: u8) -> Vec<String> {
8
7
reaction_ids
@@ -12,36 +11,6 @@ pub fn quick_reaction_glyphs(reaction_ids: &[String], skin_tone: u8) -> Vec<Stri
12
11
.collect()
13
12
}
14
13
15
/// The most used reactions first, the account defaults fill the remaining slots.
16
pub fn quick_reactions_with_usage(
17
most_used: Vec<String>,
18
defaults: Vec<String>,
19
skin_tone: u8,
20
) -> Vec<String> {
21
let count = if defaults.is_empty() {
22
teams_core::TEAMS_DEFAULT_REACTIONS.len()
23
} else {
24
defaults.len()
25
};
26
let mut quick: Vec<String> = Vec::with_capacity(count);
27
let toned_used = most_used
28
.into_iter()
29
.map(|glyph| emoticons::with_tone(&glyph, skin_tone));
30
for glyph in toned_used.chain(defaults) {
31
if quick.len() == count {
32
break;
33
}
34
let base = reaction_glyph(&emoticons::without_tone(&glyph));
35
if !quick
36
.iter()
37
.any(|known| reaction_glyph(&emoticons::without_tone(known)) == base)
38
{
39
quick.push(glyph);
40
}
41
}
42
quick
43
}
44
45
14
pub fn reaction_id_for_glyph(glyph: &str) -> Option<String> {
46
15
chatsvc::reaction_key(&emoticons::without_tone(glyph))
47
16
}
@@ -74,12 +43,10 @@ impl AppState {
74
43
teams_core::default_reactions(&self.store)
75
44
}
76
45
77
pub fn quick_reactions(&self, most_used: Vec<String>) -> Vec<String> {
78
let skin_tone = teams_core::skin_tone(&self.store);
79
quick_reactions_with_usage(
80
most_used,
81
quick_reaction_glyphs(&self.default_reactions(), skin_tone),
82
skin_tone,
46
pub fn quick_reactions(&self) -> Vec<String> {
47
quick_reaction_glyphs(
48
&self.default_reactions(),
49
teams_core::skin_tone(&self.store),
83
50
)
84
51
}
85
52
@@ -114,32 +81,6 @@ mod tests {
114
81
values.iter().map(|value| (*value).to_owned()).collect()
115
82
}
116
83
117
#[test]
118
fn most_used_come_first_and_defaults_fill_the_rest() {
119
let defaults = quick_reaction_glyphs(&ids(&teams_core::TEAMS_DEFAULT_REACTIONS), 0);
120
let quick = quick_reactions_with_usage(
121
vec!["\u{1F680}".to_owned(), "\u{2764}\u{FE0F}".to_owned()],
122
defaults.clone(),
123
0,
124
);
125
assert_eq!(quick.len(), defaults.len());
126
assert_eq!(quick[0], "\u{1F680}");
127
assert_eq!(quick[1], "\u{2764}\u{FE0F}");
128
assert_eq!(quick[2], defaults[0]);
129
assert_eq!(
130
quick.iter().filter(|glyph| reaction_glyph(glyph) == "\u{2764}").count(),
131
1
132
);
133
}
134
135
#[test]
136
fn used_reactions_take_the_account_tone() {
137
let defaults = quick_reaction_glyphs(&ids(&teams_core::TEAMS_DEFAULT_REACTIONS), 2);
138
let quick = quick_reactions_with_usage(vec!["\u{1F44D}".to_owned()], defaults, 2);
139
assert_eq!(quick[0], "\u{1F44D}\u{1F3FC}");
140
assert_eq!(quick.iter().filter(|glyph| glyph.starts_with('\u{1F44D}')).count(), 1);
141
}
142
143
84
#[test]
144
85
fn teams_defaults_show_as_glyphs_and_like_takes_the_tone() {
145
86
let defaults = ids(&teams_core::TEAMS_DEFAULT_REACTIONS);
@@ -2,7 +2,6 @@ use gpui_kit::Context;2
2
3
use crate::app_state::AppState;3
use crate::app_state::AppState;4
use crate::emoticons;4
use crate::emoticons;5
use crate::rows::reaction_glyph;6
5
7
pub fn quick_reaction_glyphs(reaction_ids: &[String], skin_tone: u8) -> Vec<String> {6
pub fn quick_reaction_glyphs(reaction_ids: &[String], skin_tone: u8) -> Vec<String> {8
reaction_ids7
reaction_ids@@ -12,36 +11,6 @@ pub fn quick_reaction_glyphs(reaction_ids: &[String], skin_tone: u8) -> Vec<Stri12
.collect()11
.collect()13
}12
}14
13
15
/// The most used reactions first, the account defaults fill the remaining slots.16
pub fn quick_reactions_with_usage(17
most_used: Vec<String>,18
defaults: Vec<String>,19
skin_tone: u8,20
) -> Vec<String> {21
let count = if defaults.is_empty() {22
teams_core::TEAMS_DEFAULT_REACTIONS.len()23
} else {24
defaults.len()25
};26
let mut quick: Vec<String> = Vec::with_capacity(count);27
let toned_used = most_used28
.into_iter()29
.map(|glyph| emoticons::with_tone(&glyph, skin_tone));30
for glyph in toned_used.chain(defaults) {31
if quick.len() == count {32
break;33
}34
let base = reaction_glyph(&emoticons::without_tone(&glyph));35
if !quick36
.iter()37
.any(|known| reaction_glyph(&emoticons::without_tone(known)) == base)38
{39
quick.push(glyph);40
}41
}42
quick43
}44
45
pub fn reaction_id_for_glyph(glyph: &str) -> Option<String> {14
pub fn reaction_id_for_glyph(glyph: &str) -> Option<String> {46
chatsvc::reaction_key(&emoticons::without_tone(glyph))15
chatsvc::reaction_key(&emoticons::without_tone(glyph))47
}16
}@@ -74,12 +43,10 @@ impl AppState {74
teams_core::default_reactions(&self.store)43
teams_core::default_reactions(&self.store)75
}44
}76
45
77
pub fn quick_reactions(&self, most_used: Vec<String>) -> Vec<String> {46
pub fn quick_reactions(&self) -> Vec<String> {78
let skin_tone = teams_core::skin_tone(&self.store);47
quick_reaction_glyphs(79
quick_reactions_with_usage(48
&self.default_reactions(),80
most_used,49
teams_core::skin_tone(&self.store),81
quick_reaction_glyphs(&self.default_reactions(), skin_tone),82
skin_tone,83
)50
)84
}51
}85
52
@@ -114,32 +81,6 @@ mod tests {114
values.iter().map(|value| (*value).to_owned()).collect()81
values.iter().map(|value| (*value).to_owned()).collect()115
}82
}116
83
117
#[test]118
fn most_used_come_first_and_defaults_fill_the_rest() {119
let defaults = quick_reaction_glyphs(&ids(&teams_core::TEAMS_DEFAULT_REACTIONS), 0);120
let quick = quick_reactions_with_usage(121
vec!["\u{1F680}".to_owned(), "\u{2764}\u{FE0F}".to_owned()],122
defaults.clone(),123
0,124
);125
assert_eq!(quick.len(), defaults.len());126
assert_eq!(quick[0], "\u{1F680}");127
assert_eq!(quick[1], "\u{2764}\u{FE0F}");128
assert_eq!(quick[2], defaults[0]);129
assert_eq!(130
quick.iter().filter(|glyph| reaction_glyph(glyph) == "\u{2764}").count(),131
1132
);133
}134
135
#[test]136
fn used_reactions_take_the_account_tone() {137
let defaults = quick_reaction_glyphs(&ids(&teams_core::TEAMS_DEFAULT_REACTIONS), 2);138
let quick = quick_reactions_with_usage(vec!["\u{1F44D}".to_owned()], defaults, 2);139
assert_eq!(quick[0], "\u{1F44D}\u{1F3FC}");140
assert_eq!(quick.iter().filter(|glyph| glyph.starts_with('\u{1F44D}')).count(), 1);141
}142
143
#[test]84
#[test]144
fn teams_defaults_show_as_glyphs_and_like_takes_the_tone() {85
fn teams_defaults_show_as_glyphs_and_like_takes_the_tone() {145
let defaults = ids(&teams_core::TEAMS_DEFAULT_REACTIONS);86
let defaults = ids(&teams_core::TEAMS_DEFAULT_REACTIONS);@@ -76,19 +76,7 @@ impl Recent {
76
76
}
77
77
78
78
pub fn most_used(&self, count: usize) -> Vec<String> {
79
self.ranked(count, 0)
80
}
81
82
pub fn frequently_used(&self, count: usize) -> Vec<String> {
83
self.ranked(count, 1)
84
}
85
86
fn ranked(&self, count: usize, min_uses: u32) -> Vec<String> {
87
let mut ranked: Vec<&Entry> = self
88
.0
89
.iter()
90
.filter(|entry| entry.uses >= min_uses)
91
.collect();
79
let mut ranked: Vec<&Entry> = self.0.iter().collect();
92
80
ranked.sort_by_key(|entry| std::cmp::Reverse(entry.uses));
93
81
ranked
94
82
.into_iter()
@@ -76,19 +76,7 @@ impl Recent {76
}76
}77
77
78
pub fn most_used(&self, count: usize) -> Vec<String> {78
pub fn most_used(&self, count: usize) -> Vec<String> {79
self.ranked(count, 0)79
let mut ranked: Vec<&Entry> = self.0.iter().collect();80
}81
82
pub fn frequently_used(&self, count: usize) -> Vec<String> {83
self.ranked(count, 1)84
}85
86
fn ranked(&self, count: usize, min_uses: u32) -> Vec<String> {87
let mut ranked: Vec<&Entry> = self88
.089
.iter()90
.filter(|entry| entry.uses >= min_uses)91
.collect();92
ranked.sort_by_key(|entry| std::cmp::Reverse(entry.uses));80
ranked.sort_by_key(|entry| std::cmp::Reverse(entry.uses));93
ranked81
ranked94
.into_iter()82
.into_iter()@@ -3079,11 +3079,7 @@ impl ConversationView {
3079
3079
let saved = self
3080
3080
.conversation_id()
3081
3081
.is_some_and(|conversation_id| state.is_saved(&conversation_id, key));
3082
let quick = state.quick_reactions(
3083
self.recent
3084
.read(cx)
3085
.frequently_used(teams_core::DEFAULT_REACTION_SLOTS),
3086
);
3082
let quick = state.quick_reactions();
3087
3083
let in_chat = chat_id.is_some();
3088
3084
let pin_conversation_id = self.pin_conversation_id();
3089
3085
let pinned = pin_conversation_id
@@ -3079,11 +3079,7 @@ impl ConversationView {3079
let saved = self3079
let saved = self3080
.conversation_id()3080
.conversation_id()3081
.is_some_and(|conversation_id| state.is_saved(&conversation_id, key));3081
.is_some_and(|conversation_id| state.is_saved(&conversation_id, key));3082
let quick = state.quick_reactions(3082
let quick = state.quick_reactions();3083
self.recent3084
.read(cx)3085
.frequently_used(teams_core::DEFAULT_REACTION_SLOTS),3086
);3087
let in_chat = chat_id.is_some();3083
let in_chat = chat_id.is_some();3088
let pin_conversation_id = self.pin_conversation_id();3084
let pin_conversation_id = self.pin_conversation_id();3089
let pinned = pin_conversation_id3085
let pinned = pin_conversation_id