mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Show download start date in Downloads section.
This commit is contained in:
parent
57f17b7afe
commit
5ddcf402bc
5 changed files with 30 additions and 8 deletions
|
@ -29,6 +29,10 @@ enum class DownloadType {
|
||||||
// unixtime * 1000.
|
// unixtime * 1000.
|
||||||
using DownloadDate = int64;
|
using DownloadDate = int64;
|
||||||
|
|
||||||
|
[[nodiscard]] inline TimeId DateFromDownloadDate(DownloadDate date) {
|
||||||
|
return date / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
struct DownloadId {
|
struct DownloadId {
|
||||||
uint64 objectId = 0;
|
uint64 objectId = 0;
|
||||||
DownloadType type = DownloadType::Document;
|
DownloadType type = DownloadType::Document;
|
||||||
|
|
|
@ -320,12 +320,16 @@ std::unique_ptr<BaseLayout> Provider::createLayout(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using namespace Overview::Layout;
|
||||||
auto &songSt = st::overviewFileLayout;
|
auto &songSt = st::overviewFileLayout;
|
||||||
if (const auto file = getFile()) {
|
if (const auto file = getFile()) {
|
||||||
return std::make_unique<Overview::Layout::Document>(
|
return std::make_unique<Document>(
|
||||||
delegate,
|
delegate,
|
||||||
element.item,
|
element.item,
|
||||||
file,
|
DocumentFields{
|
||||||
|
.document = file,
|
||||||
|
.dateOverride = Data::DateFromDownloadDate(element.started),
|
||||||
|
},
|
||||||
songSt);
|
songSt);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -432,12 +432,20 @@ std::unique_ptr<BaseLayout> Provider::createLayout(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
case Type::File:
|
case Type::File:
|
||||||
if (const auto file = getFile()) {
|
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;
|
return nullptr;
|
||||||
case Type::MusicFile:
|
case Type::MusicFile:
|
||||||
if (const auto file = getFile()) {
|
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;
|
return nullptr;
|
||||||
case Type::RoundVoiceFile:
|
case Type::RoundVoiceFile:
|
||||||
|
|
|
@ -920,10 +920,10 @@ bool Voice::updateStatusText() {
|
||||||
Document::Document(
|
Document::Document(
|
||||||
not_null<Delegate*> delegate,
|
not_null<Delegate*> delegate,
|
||||||
not_null<HistoryItem*> parent,
|
not_null<HistoryItem*> parent,
|
||||||
not_null<DocumentData*> document,
|
DocumentFields fields,
|
||||||
const style::OverviewFileLayout &st)
|
const style::OverviewFileLayout &st)
|
||||||
: RadialProgressItem(delegate, parent)
|
: RadialProgressItem(delegate, parent)
|
||||||
, _data(document)
|
, _data(fields.document)
|
||||||
, _msgl(goToMessageClickHandler(parent))
|
, _msgl(goToMessageClickHandler(parent))
|
||||||
, _namel(std::make_shared<DocumentOpenClickHandler>(
|
, _namel(std::make_shared<DocumentOpenClickHandler>(
|
||||||
_data,
|
_data,
|
||||||
|
@ -933,7 +933,9 @@ Document::Document(
|
||||||
parent->fullId()))
|
parent->fullId()))
|
||||||
, _st(st)
|
, _st(st)
|
||||||
, _generic(::Layout::DocumentGenericPreview::Create(_data))
|
, _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)
|
, _ext(_generic.ext)
|
||||||
, _datew(st::normalFont->width(_date)) {
|
, _datew(st::normalFont->width(_date)) {
|
||||||
_name.setMarkedText(
|
_name.setMarkedText(
|
||||||
|
|
|
@ -335,12 +335,16 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DocumentFields {
|
||||||
|
not_null<DocumentData*> document;
|
||||||
|
TimeId dateOverride = 0;
|
||||||
|
};
|
||||||
class Document final : public RadialProgressItem {
|
class Document final : public RadialProgressItem {
|
||||||
public:
|
public:
|
||||||
Document(
|
Document(
|
||||||
not_null<Delegate*> delegate,
|
not_null<Delegate*> delegate,
|
||||||
not_null<HistoryItem*> parent,
|
not_null<HistoryItem*> parent,
|
||||||
not_null<DocumentData*> document,
|
DocumentFields fields,
|
||||||
const style::OverviewFileLayout &st);
|
const style::OverviewFileLayout &st);
|
||||||
|
|
||||||
void initDimensions() override;
|
void initDimensions() override;
|
||||||
|
|
Loading…
Add table
Reference in a new issue