Closed levochkaa closed 1 year ago
This pull request belongs to the #26 issue
Also, I don't get the propose of using TdInt64
and not using just Int64
@Kylmakalle may you explain this a bit?
Follow-up on Identifiable - https://t.me/tdlibchat/72102
Identifiable is just a trait, which means that the class has field id. It implies nothing about id uniqueness, so it is safe to use it for all classes with id field
@levochkaa got a chance to test the Hashable protocol with TDLibKit?
Also, I don't get the propose of using TdInt64 and not using just Int64
Good question, here's the answer
https://core.telegram.org/tdlib/docs/td__api_8h.html#a552928ab323811c9694f5b7c9f53d0fb
This type is used to store 64-bit signed integers, which can't be represented as Number in JSON and are represented as String instead.
@levochkaa Please, Bump minor version in the root directory
@Kylmakalle
Identifiable is just a trait, which means that the class has field id. It implies nothing about id uniqueness, so it is safe to use it for all classes with id field
that's of course true, but if the id won't be unique, there can be some bugs in SwiftUI.
I was thinking about it for a while and came to this:
Identifiable stays for struct's with id
property, because for 99.99% that won't cause any bugs and it would be just easier to write some simple code. And when making a bigger app (like mine BetterTG or Ggora's Moc) you won't really use simple TDLib structs, because they would be pretty useless.
(Also, when needed, I was making the struct Identifiable or fake Identifiable sometimes, never got bugs with that)
And, if someone comes up with a bug with uniqueness of Identifiable structs, I hope -- he will open an Issue and that specific case would be discussed or fixed in the script.
And, you can use Hashable for uniqueness, so, no problems with that
Follow-up on Identifiable - t.me/tdlibchat/72102
Btw, thx for the chat. I've checked the discussion, voting for struct's to be Identifiable still😅
@levochkaa got a chance to test the Hashable protocol with TDLibKit?
Nope, but what can happen, also, I've used it few times (as I said in previous messages), and the coder, that opened an Issue did that Adopting to Hashable is just annoying, when doing it from the app, not from the TDLibKit
@levochkaa Please, Bump minor version in the root directory
Bumped
Also, I don't get the propose of using TdInt64 and not using just Int64
Good question, here's the answer
core.telegram.org/tdlib/docs/td__api_8h.html#a552928ab323811c9694f5b7c9f53d0fb
This type is used to store 64-bit signed integers, which can't be represented as Number in JSON and are represented as String instead.
Wow, thanks, now I know
Nope, but what can happen, also, I've used it few times (as I said in previous messages), and the coder, that opened an Issue did that Adopting to Hashable is just annoying, when doing it from the app, not from the TDLibKit
@levochkaa I meant, have you tried this branch with some application that can benefit from the Hashable
Nope, but what can happen, also, I've used it few times (as I said in previous messages), and the coder, that opened an Issue did that
Adopting to Hashable is just annoying, when doing it from the app, not from the TDLibKit
@levochkaa I meant, have you tried this branch with some application that can benefit from the
Hashable
Now i get, Ok, will give an example app in a few days
Made an example usage of Identifiable protocol in a List and using Hashable protocol in new iOS 16 SwiftUI NavigationStack I've made the app really simple, but showing how useful it can be
(Without Hashable protocol in models the new navigation usage is almost impossible)
@levochkaa thank you for the contribution and comprehensive example! Feel free to provide more additions that will help TDLibKit to be easily integrated into SwiftUI
I don't see any problems with adding
Hashable
protocol conformance, even to theTdInt64
, that should be ok.Identifiable
is a bit more complicated: I've checked all the structs that now getsIdentifiable
conformance and most of them mention, thatid
is "Unique", but some of them don't, even if it is an identifier of theUser
struct, that must be unique AFAIK.I see two possible variants to deal with Identifiable:
Identifiable
conformance, only if theid
is mentioned in the comment as "Unique".I would prefer the second variant.