| 254 | } |
| 255 | |
| 256 | std::unique_ptr<PeerListRow> InactiveController::createRow( |
| 257 | not_null<PeerData*> peer, |
| 258 | TimeId date) const { |
| 259 | auto result = std::make_unique<PeerListRow>(peer); |
| 260 | const auto active = base::unixtime::parse(date).date(); |
| 261 | const auto now = QDate::currentDate(); |
| 262 | const auto time = [&] { |
| 263 | const auto days = active.daysTo(now); |
| 264 | if (now < active) { |
| 265 | return QString(); |
| 266 | } else if (active == now) { |
| 267 | const auto unixtime = base::unixtime::now(); |
| 268 | const auto delta = int64(unixtime) - int64(date); |
| 269 | if (delta <= 0) { |
| 270 | return QString(); |
| 271 | } else if (delta >= 3600) { |
| 272 | return tr::lng_hours(tr::now, lt_count, delta / 3600); |
| 273 | } else if (delta >= 60) { |
| 274 | return tr::lng_minutes(tr::now, lt_count, delta / 60); |
| 275 | } else { |
| 276 | return tr::lng_seconds(tr::now, lt_count, delta); |
| 277 | } |
| 278 | } else if (days >= 365) { |
| 279 | return tr::lng_years(tr::now, lt_count, days / 365); |
| 280 | } else if (days >= 31) { |
| 281 | return tr::lng_months(tr::now, lt_count, days / 31); |
| 282 | } else if (days >= 7) { |
| 283 | return tr::lng_weeks(tr::now, lt_count, days / 7); |
| 284 | } else { |
| 285 | return tr::lng_days(tr::now, lt_count, days); |
| 286 | } |
| 287 | }(); |
| 288 | result->setCustomStatus(tr::lng_channels_leave_status( |
| 289 | tr::now, |
| 290 | lt_type, |
| 291 | (peer->isBroadcast() |
| 292 | ? tr::lng_channel_status(tr::now) |
| 293 | : tr::lng_group_status(tr::now)), |
| 294 | lt_time, |
| 295 | time)); |
| 296 | return result; |
| 297 | } |
| 298 | |
| 299 | PublicsController::PublicsController( |
| 300 | not_null<Window::SessionNavigation*> navigation, |
nothing calls this directly
no test coverage detected