Show download start date in Downloads section.

This commit is contained in:
John Preston 2022-02-26 19:48:12 +03:00
parent 57f17b7afe
commit 5ddcf402bc
5 changed files with 30 additions and 8 deletions

View file

@ -29,6 +29,10 @@ enum class DownloadType {
// unixtime * 1000.
using DownloadDate = int64;
[[nodiscard]] inline TimeId DateFromDownloadDate(DownloadDate date) {
return date / 1000;
}
struct DownloadId {
uint64 objectId = 0;
DownloadType type = DownloadType::Document;

View file

@ -320,12 +320,16 @@ std::unique_ptr<BaseLayout> Provider::createLayout(
return nullptr;
};
using namespace Overview::Layout;
auto &songSt = st::overviewFileLayout;
if (const auto file = getFile()) {
return std::make_unique<Overview::Layout::Document>(
return std::make_unique<Document>(
delegate,
element.item,
file,
DocumentFields{
.document = file,
.dateOverride = Data::DateFromDownloadDate(element.started),
},
songSt);
}
return nullptr;

View file

@ -432,12 +432,20 @@ std::unique_ptr<BaseLayout> Provider::createLayout(
return nullptr;
case Type::File:
if (const auto file = getFile()) {
return std::make_unique<Document>(delegate, item, file, songSt);
return std::make_unique<Document>(
delegate,
item,
DocumentFields{ .document = file },
songSt);
}
return nullptr;
case Type::MusicFile:
if (const auto file = getFile()) {
return std::make_unique<Document>(delegate, item, file, songSt);
return std::make_unique<Document>(
delegate,
item,
DocumentFields{ .document = file },
songSt);
}
return nullptr;
case Type::RoundVoiceFile:

View file

@ -920,10 +920,10 @@ bool Voice::updateStatusText() {
Document::Document(
not_null<Delegate*> delegate,
not_null<HistoryItem*> parent,
not_null<DocumentData*> document,
DocumentFields fields,
const style::OverviewFileLayout &st)
: RadialProgressItem(delegate, parent)
, _data(document)
, _data(fields.document)
, _msgl(goToMessageClickHandler(parent))
, _namel(std::make_shared<DocumentOpenClickHandler>(
_data,
@ -933,7 +933,9 @@ Document::Document(
parent->fullId()))
, _st(st)
, _generic(::Layout::DocumentGenericPreview::Create(_data))
, _date(langDateTime(base::unixtime::parse(_data->date)))
, _date(langDateTime(base::unixtime::parse(fields.dateOverride
? fields.dateOverride
: _data->date)))
, _ext(_generic.ext)
, _datew(st::normalFont->width(_date)) {
_name.setMarkedText(

View file

@ -335,12 +335,16 @@ private:
};
struct DocumentFields {
not_null<DocumentData*> document;
TimeId dateOverride = 0;
};
class Document final : public RadialProgressItem {
public:
Document(
not_null<Delegate*> delegate,
not_null<HistoryItem*> parent,
not_null<DocumentData*> document,
DocumentFields fields,
const style::OverviewFileLayout &st);
void initDimensions() override;