{{--
Thread and reply form of the SMS conversation page (#2957 slice 5b, card #3019).
Sent messages sit right on a tinted background, replies left on white, a day divider above the
first message of each day (Idag, Igår or the date) and the time under each message, as before;
replies that were unread when the page opened say Oläst (the controller has marked them read since).
The reply form posts the old fields to sms-sendout.store: sendout_id, parent_id, receiver_id,
reply (the first message's third party id), parts (written by sms-form.js) and message.
--}}
@php
$types = \App\Models\SMS::$type;
$messages = collect($conversation)->map(fn ($message) => (object) $message)
->filter(fn ($message) => in_array((int) $message->type, [$types['sent'], $types['received']], true))->values();
$first = collect($conversation)->map(fn ($message) => (object) $message)->first();
$dayLabel = function ($day) {
if ($day->isToday()) {
return __('sms.edit.today');
}
if ($day->isYesterday()) {
return __('sms.edit.yesterday');
}
return $day->copy()->locale(app()->getLocale())->isoFormat($day->isCurrentYear() ? 'dddd D MMMM' : 'dddd D MMMM YYYY');
};
$previousDay = null;
@endphp