ContactList.fromEvent constructor
ContactList.fromEvent(
- Nip01Event event
Implementation
ContactList.fromEvent(Nip01Event event) {
pubKey = event.pubKey;
createdAt = event.createdAt;
loadedTimestamp = DateTime.now().millisecondsSinceEpoch ~/ 1000;
for (var tag in event.tags) {
final length = tag.length;
if (length <= 1) continue;
final name = tag[0];
final contact = tag[1];
if (name == "p") {
String relay = '';
String petname = '';
if (length > 2) {
relay = tag[2];
if (length > 3) {
petname = tag[3];
}
}
contacts.add(contact);
contactRelays.add(relay);
petnames.add(petname);
} else if (name == "t" && length > 1) {
var tagName = tag[1];
followedTags.add(tagName);
} else if (name == "a" && length > 1) {
var id = tag[1];
followedCommunities.add(id);
} else if (name == "e" && length > 1) {
var id = tag[1];
followedEvents.add(id);
}
}
sources.addAll(event.sources);
}