|
1 | 1 | use gpui::Rgba;
|
2 |
| -use scope_chat::reaction::{MessageReaction, MessageReactionType, ReactionEmoji, ReactionList, ReactionOperation}; |
| 2 | +use scope_chat::reaction::{MessageReaction, MessageReactionType, ReactionEmoji}; |
3 | 3 | use serenity::all::ReactionType;
|
4 | 4 | use MessageReactionType::Burst;
|
5 | 5 | use scope_chat::reaction::MessageReactionType::Normal;
|
@@ -138,72 +138,6 @@ impl MessageReaction for DiscordMessageReaction {
|
138 | 138 | }
|
139 | 139 | }
|
140 | 140 |
|
141 |
| -#[derive(Clone, Debug, Default)] |
142 |
| -pub struct DiscordReactionList { |
143 |
| - reactions: Vec<DiscordMessageReaction>, |
144 |
| -} |
145 |
| - |
146 |
| -impl DiscordReactionList { |
147 |
| - pub fn new(reactions: Vec<DiscordMessageReaction>) -> Self { |
148 |
| - DiscordReactionList { reactions } |
149 |
| - } |
150 |
| -} |
151 |
| - |
152 |
| -impl ReactionList for DiscordReactionList { |
153 |
| - fn get_reactions(&self) -> &Vec<impl MessageReaction> { |
154 |
| - &self.reactions |
155 |
| - } |
156 |
| - |
157 |
| - fn get_reaction(&self, emoji: &ReactionEmoji) -> Option<&impl MessageReaction> { |
158 |
| - self.reactions.iter().find(|reaction| reaction.get_emoji() == *emoji) |
159 |
| - } |
160 |
| - |
161 |
| - fn increment(&mut self, emoji: &ReactionEmoji, kind: MessageReactionType, user_is_self: bool, by: isize) { |
162 |
| - if let Some(reaction) = self.reactions.iter_mut().find(|reaction| reaction.get_emoji() == *emoji) { |
163 |
| - reaction.increment(kind, user_is_self, by); |
164 |
| - if reaction.get_count(None) == 0 { |
165 |
| - self.reactions.retain(|reaction| reaction.get_emoji() != *emoji); |
166 |
| - } |
167 |
| - } else if by > 0 { |
168 |
| - let mut reaction = DiscordMessageReaction { |
169 |
| - data: ReactionData::Local { |
170 |
| - count_normal: 0, |
171 |
| - count_burst: 0, |
172 |
| - me: None, |
173 |
| - emoji: emoji.clone(), |
174 |
| - burst_colours: vec![], |
175 |
| - }, |
176 |
| - }; |
177 |
| - |
178 |
| - reaction.increment(kind, user_is_self, by); |
179 |
| - self.reactions.push(reaction); |
180 |
| - } |
181 |
| - } |
182 |
| - |
183 |
| - fn apply(&mut self, operation: ReactionOperation) { |
184 |
| - match operation { |
185 |
| - ReactionOperation::Add(emoji, ty) => { |
186 |
| - self.increment(&emoji, ty, false, 1); |
187 |
| - } |
188 |
| - ReactionOperation::AddSelf(emoji, ty) => { |
189 |
| - self.increment(&emoji, ty, true, 1); |
190 |
| - } |
191 |
| - ReactionOperation::Remove(emoji) => { |
192 |
| - self.increment(&emoji, Normal, false, -1); |
193 |
| - } |
194 |
| - ReactionOperation::RemoveSelf(emoji) => { |
195 |
| - self.increment(&emoji, Normal, true, -1); |
196 |
| - } |
197 |
| - ReactionOperation::RemoveAll => { |
198 |
| - self.reactions.clear(); |
199 |
| - } |
200 |
| - ReactionOperation::RemoveEmoji(emoji) => { |
201 |
| - self.reactions.retain(|reaction| reaction.get_emoji() != emoji); |
202 |
| - } |
203 |
| - } |
204 |
| - } |
205 |
| -} |
206 |
| - |
207 | 141 | pub fn discord_reaction_to_emoji(reaction: &serenity::all::ReactionType) -> ReactionEmoji {
|
208 | 142 | match reaction {
|
209 | 143 | ReactionType::Custom { animated, id, name } => ReactionEmoji::Custom {
|
|
0 commit comments