| 205 | const days = Math.floor( |
| 206 | (Date.now() - Number(user.status.wasOnline) * 1000) / DAY_MS, |
| 207 | ); |
| 208 | return Math.max(0, days); |
| 209 | } |
| 210 | if (user.status instanceof Api.UserStatusLastWeek) return 7; |
| 211 | if (user.status instanceof Api.UserStatusLastMonth) return 30; |
| 212 | return null; |
| 213 | } |
| 214 | |
| 215 | function getUserIdString(user: Api.User): string { |
| 216 | return String(user.id); |
| 217 | } |
| 218 | |
| 219 | function getUserDisplayName(user: Api.User): string { |
| 220 | const parts = [user.firstName || "", user.lastName || ""] |
| 221 | .map((part) => part.trim()) |
| 222 | .filter(Boolean); |
| 223 | if (parts.length > 0) return parts.join(" "); |
| 224 | if (user.username) return user.username; |
| 225 | return getUserIdString(user); |
| 226 | } |
| 227 | |
| 228 | function buildTargetDisplay(target: TargetChat): string { |