mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-25 01:50:36 +00:00
Moved out generating unique PeerListRowId from string to single place.
This commit is contained in:
parent
1851b6ff30
commit
1852161fbf
@ -37,8 +37,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "styles/style_menu_icons.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
#include <xxhash.h>
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr auto kMaxLinkTitleLength = 32;
|
||||
@ -223,14 +221,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] uint64 ComputeRowId(const QString &link) {
|
||||
return XXH64(link.data(), link.size() * sizeof(ushort), 0);
|
||||
}
|
||||
|
||||
[[nodiscard]] uint64 ComputeRowId(const InviteLinkData &data) {
|
||||
return ComputeRowId(data.url);
|
||||
}
|
||||
|
||||
[[nodiscard]] Color ComputeColor(const InviteLinkData &link) {
|
||||
return Color::Permanent;
|
||||
}
|
||||
@ -242,7 +232,7 @@ private:
|
||||
LinkRow::LinkRow(
|
||||
not_null<LinkRowDelegate*> delegate,
|
||||
const InviteLinkData &data)
|
||||
: PeerListRow(ComputeRowId(data))
|
||||
: PeerListRow(UniqueRowIdFromString(data.url))
|
||||
, _delegate(delegate)
|
||||
, _data(data)
|
||||
, _color(ComputeColor(data)) {
|
||||
|
@ -35,6 +35,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "styles/style_dialogs.h"
|
||||
#include "styles/style_widgets.h"
|
||||
|
||||
#include <xxhash.h> // XXH64.
|
||||
|
||||
[[nodiscard]] PeerListRowId UniqueRowIdFromString(const QString &d) {
|
||||
return XXH64(d.data(), d.size() * sizeof(ushort), 0);
|
||||
}
|
||||
|
||||
PaintRoundImageCallback PaintUserpicCallback(
|
||||
not_null<PeerData*> peer,
|
||||
bool respectSavedMessagesChat) {
|
||||
|
@ -54,6 +54,8 @@ using PaintRoundImageCallback = Fn<void(
|
||||
|
||||
using PeerListRowId = uint64;
|
||||
|
||||
[[nodiscard]] PeerListRowId UniqueRowIdFromString(const QString &d);
|
||||
|
||||
class PeerListRow {
|
||||
public:
|
||||
enum class State {
|
||||
|
@ -32,8 +32,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "styles/style_settings.h" // st::settingsDividerLabelPadding
|
||||
#include "styles/style_menu_icons.h"
|
||||
|
||||
#include <xxhash.h>
|
||||
|
||||
namespace {
|
||||
|
||||
enum class Color {
|
||||
@ -112,12 +110,8 @@ private:
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] uint64 ComputeRowId(const QString &link) {
|
||||
return XXH64(link.data(), link.size() * sizeof(ushort), 0);
|
||||
}
|
||||
|
||||
[[nodiscard]] uint64 ComputeRowId(const InviteLinkData &data) {
|
||||
return ComputeRowId(data.link);
|
||||
return UniqueRowIdFromString(data.link);
|
||||
}
|
||||
|
||||
[[nodiscard]] float64 ComputeProgress(
|
||||
@ -628,7 +622,8 @@ void LinksController::updateRow(const InviteLinkData &data, TimeId now) {
|
||||
}
|
||||
|
||||
bool LinksController::removeRow(const QString &link) {
|
||||
if (const auto row = delegate()->peerListFindRow(ComputeRowId(link))) {
|
||||
const auto id = UniqueRowIdFromString(link);
|
||||
if (const auto row = delegate()->peerListFindRow(id)) {
|
||||
delegate()->peerListRemoveRow(row);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user