41 lines
1.3 KiB
Dart
41 lines
1.3 KiB
Dart
import 'package:get_it/get_it.dart';
|
|
|
|
import '../controller/settings.dart';
|
|
import '../../services/notification.dart';
|
|
import 'companies.dart';
|
|
import 'event_organisations.dart';
|
|
import 'interfaces.dart';
|
|
|
|
class PushNotificationTopicModel with Name, IsSubscribable {
|
|
|
|
final String id;
|
|
final String name;
|
|
get subscribed => SettingsController.subscribed(this);
|
|
subscribe(bool subscribe) {
|
|
if(subscribe) {
|
|
SettingsController.subscribeTopic(this);
|
|
ExternalNotificationConnector.subscribe(this);
|
|
} else {
|
|
SettingsController.unsubscribeTopic(this);
|
|
ExternalNotificationConnector.unsubscribe(this);
|
|
}
|
|
}
|
|
|
|
const PushNotificationTopicModel(this.id, this.name);
|
|
|
|
factory PushNotificationTopicModel.fromJson(Map<String, dynamic> json) {
|
|
return PushNotificationTopicModel(
|
|
json['id'] as String,
|
|
json['name'] as String
|
|
);
|
|
}
|
|
|
|
static List<PushNotificationTopicModel> values = GetIt.I<List<PushNotificationTopicModel>>()..addAll(EventOrganisationModel.values)..addAll(CompanyModel.values)..sort((a, b) => a.name.compareTo(b.name));
|
|
|
|
bool operator ==(Object other) =>
|
|
other is PushNotificationTopicModel &&
|
|
runtimeType == other.runtimeType &&
|
|
id == other.id;
|
|
|
|
int get hashCode => id.hashCode;
|
|
} |