Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/src/api/domains.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class MbinAPIDomains {
return DomainModel.fromMbin(response.bodyJson);
}

Future<DomainModel> getByName(String domain) async {
return (await list(search: domain)).items.first;
}

Future<DomainModel> putSubscribe(int domainId, bool state) async {
final path = '/domain/$domainId/${state ? 'subscribe' : 'unsubscribe'}';

Expand Down
9 changes: 7 additions & 2 deletions lib/src/controller/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,9 @@ class AppController with ChangeNotifier {
.insertOnConflictUpdate(
FeedInputsCompanion.insert(
feed: name,
name: normalizeName(input.name, instanceHost),
name: input.sourceType == FeedSource.domain
? input.name
: normalizeName(input.name, instanceHost),
source: input.sourceType,
),
);
Expand Down Expand Up @@ -1003,7 +1005,9 @@ class AppController with ChangeNotifier {
}

Future<int?> fetchCachedFeedInput(String name, FeedSource source) async {
final normalisedName = normalizeName(name, instanceHost);
final normalisedName = source == FeedSource.domain
? name
: normalizeName(name, instanceHost);
final cachedValue =
(await (database.select(database.feedSourceCache)..where(
(t) =>
Expand All @@ -1028,6 +1032,7 @@ class AppController with ChangeNotifier {
instanceHost // tmp until proper getByName method can be made
? throw Exception('Wrong instance')
: int.parse(name.split(':').first),
FeedSource.domain => (await api.domains.getByName(normalisedName)).id,
_ => null,
};

Expand Down
3 changes: 1 addition & 2 deletions lib/src/screens/explore/explore_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ class _ExploreScreenState extends State<ExploreScreen> {
padding: chipPadding,
),
const SizedBox(width: 4),
if (ac.serverSoftware == ServerSoftware.mbin &&
_selected == null) ...[
if (ac.serverSoftware == ServerSoftware.mbin) ...[
ChoiceChip(
label: Text(l(context).domains),
selected: type == ExploreType.domains,
Expand Down
16 changes: 10 additions & 6 deletions lib/src/screens/settings/feed_settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,17 @@ class _EditFeedScreenState extends State<EditFeedScreen> {
)
.toSet(),
onTap: (selected, item) {
var name = switch (item) {
final DetailedCommunityModel i => i.name,
final DetailedUserModel i => i.name,
final name = switch (item) {
final DetailedCommunityModel i => normalizeName(
i.name,
ac.instanceHost,
),
final DetailedUserModel i => normalizeName(
i.name,
ac.instanceHost,
),
final DomainModel i => i.name,
final FeedModel i => i.name,
final FeedModel i => normalizeName(i.name, ac.instanceHost),
_ => null,
};
final source = switch (item) {
Expand All @@ -550,8 +556,6 @@ class _EditFeedScreenState extends State<EditFeedScreen> {

if (name == null || source == null) return;

name = normalizeName(name, ac.instanceHost);

if (selected) {
addInput(
FeedInput(name: name, sourceType: source, serverId: id),
Expand Down
Loading