init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
105
Telegram/SourceFiles/api/api_send_progress.h
Normal file
105
Telegram/SourceFiles/api/api_send_progress.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "api/api_common.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
class History;
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Api {
|
||||
|
||||
enum class SendProgressType {
|
||||
Typing,
|
||||
RecordVideo,
|
||||
UploadVideo,
|
||||
RecordVoice,
|
||||
UploadVoice,
|
||||
RecordRound,
|
||||
UploadRound,
|
||||
UploadPhoto,
|
||||
UploadFile,
|
||||
ChooseLocation,
|
||||
ChooseContact,
|
||||
ChooseSticker,
|
||||
PlayGame,
|
||||
Speaking,
|
||||
};
|
||||
|
||||
struct SendProgress {
|
||||
SendProgress(
|
||||
SendProgressType type,
|
||||
crl::time until,
|
||||
int progress = 0)
|
||||
: type(type)
|
||||
, until(until)
|
||||
, progress(progress) {
|
||||
}
|
||||
SendProgressType type = SendProgressType::Typing;
|
||||
crl::time until = 0;
|
||||
int progress = 0;
|
||||
|
||||
};
|
||||
|
||||
class SendProgressManager final {
|
||||
public:
|
||||
SendProgressManager(not_null<Main::Session*> session);
|
||||
|
||||
void update(
|
||||
not_null<History*> history,
|
||||
SendProgressType type,
|
||||
int progress = 0);
|
||||
void update(
|
||||
not_null<History*> history,
|
||||
MsgId topMsgId,
|
||||
SendProgressType type,
|
||||
int progress = 0);
|
||||
void cancel(
|
||||
not_null<History*> history,
|
||||
MsgId topMsgId,
|
||||
SendProgressType type);
|
||||
void cancel(
|
||||
not_null<History*> history,
|
||||
SendProgressType type);
|
||||
void cancelTyping(not_null<History*> history);
|
||||
|
||||
private:
|
||||
struct Key {
|
||||
not_null<History*> history;
|
||||
MsgId topMsgId = 0;
|
||||
SendProgressType type = SendProgressType();
|
||||
|
||||
inline bool operator<(const Key &other) const {
|
||||
return (history < other.history)
|
||||
|| (history == other.history && topMsgId < other.topMsgId)
|
||||
|| (history == other.history
|
||||
&& topMsgId == other.topMsgId
|
||||
&& type < other.type);
|
||||
}
|
||||
};
|
||||
|
||||
bool updated(const Key &key, bool doing);
|
||||
|
||||
void send(const Key &key, int progress);
|
||||
void done(mtpRequestId requestId);
|
||||
|
||||
[[nodiscard]] bool skipRequest(const Key &key) const;
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
base::flat_map<Key, mtpRequestId> _requests;
|
||||
base::flat_map<Key, crl::time> _updated;
|
||||
base::Timer _stopTypingTimer;
|
||||
History *_stopTypingHistory = nullptr;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Api
|
||||
Reference in New Issue
Block a user