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
6 changes: 3 additions & 3 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@
"channelName": {"type": "String", "example": "mobile"}
}
},
"unsubscribeConfirmationDialogMessageMaybeCannotResubscribe": "Once you leave this channel, you might not be able to rejoin.",
"@unsubscribeConfirmationDialogMessageMaybeCannotResubscribe": {
"description": "Message for a confirmation dialog for unsubscribing from a channel when you might not have permission to resubscribe."
"unsubscribeConfirmationDialogMessageCannotResubscribe": "Once you leave this channel, you will not be able to rejoin.",
"@unsubscribeConfirmationDialogMessageCannotResubscribe": {
"description": "Message for a confirmation dialog for unsubscribing from a channel when you will not have permission to resubscribe."
},
"unsubscribeConfirmationDialogConfirmButton": "Unsubscribe",
"@unsubscribeConfirmationDialogConfirmButton": {
Expand Down
6 changes: 3 additions & 3 deletions lib/generated/l10n/zulip_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ abstract class ZulipLocalizations {
/// **'Unsubscribe from {channelName}?'**
String unsubscribeConfirmationDialogTitle(String channelName);

/// Message for a confirmation dialog for unsubscribing from a channel when you might not have permission to resubscribe.
/// Message for a confirmation dialog for unsubscribing from a channel when you will not have permission to resubscribe.
///
/// In en, this message translates to:
/// **'Once you leave this channel, you might not be able to rejoin.'**
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe;
/// **'Once you leave this channel, you will not be able to rejoin.'**
String get unsubscribeConfirmationDialogMessageCannotResubscribe;

/// Label for the 'Unsubscribe' button on a confirmation dialog for unsubscribing from a channel.
///
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Once you leave this channel, you might not be able to rejoin.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Unsubscribe';
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class ZulipLocalizationsDe extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Wenn du diesen Kanal verlässt, kannst du sich vielleicht nicht wieder beitreten.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Deabonnieren';
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Once you leave this channel, you might not be able to rejoin.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Unsubscribe';
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class ZulipLocalizationsFr extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Once you leave this channel, you might not be able to rejoin.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Se désinscrire';
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_it.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class ZulipLocalizationsIt extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Once you leave this channel, you might not be able to rejoin.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Unsubscribe';
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'このチャンネルを退出すると、再び参加できない可能性があります。';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'チャンネルから退出';
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_nb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Once you leave this channel, you might not be able to rejoin.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Unsubscribe';
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Po opuszczeniu kanału możesz utracić możliwość powrotu.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Odsubskrybuj';
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Покинув этот канал, возможно, вы не сможете присоединиться вновь.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Отписаться';
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_sk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Once you leave this channel, you might not be able to rejoin.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Unsubscribe';
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_sl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class ZulipLocalizationsSl extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Ko zapustite ta kanal, se morda ne boste mogli znova pridružiti.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Prekliči naročnino';
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations_uk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ class ZulipLocalizationsUk extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Після того, як ви залишите цей канал, ви, можливо, не зможете приєднатися знову.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Скасувати підписку';
Expand Down
12 changes: 2 additions & 10 deletions lib/generated/l10n/zulip_localizations_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class ZulipLocalizationsZh extends ZulipLocalizations {
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'Once you leave this channel, you might not be able to rejoin.';
String get unsubscribeConfirmationDialogMessageCannotResubscribe =>
'Once you leave this channel, you will not be able to rejoin.';

@override
String get unsubscribeConfirmationDialogConfirmButton => 'Unsubscribe';
Expand Down Expand Up @@ -1254,10 +1254,6 @@ class ZulipLocalizationsZhHansCn extends ZulipLocalizationsZh {
return '确定取消订阅$channelName么?';
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'一旦退出该频道,您可能无法重新加入。';

@override
String get unsubscribeConfirmationDialogConfirmButton => '取消订阅';

Expand Down Expand Up @@ -2342,10 +2338,6 @@ class ZulipLocalizationsZhHantTw extends ZulipLocalizationsZh {
return '確定要取消訂閱 $channelName 嗎?';
}

@override
String get unsubscribeConfirmationDialogMessageMaybeCannotResubscribe =>
'一旦您離開此頻道,可能無法重新加入。';

@override
String get unsubscribeConfirmationDialogConfirmButton => '取消訂閱';

Expand Down
12 changes: 7 additions & 5 deletions lib/widgets/action_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import '../model/content.dart';
import '../model/emoji.dart';
import '../model/internal_link.dart';
import '../model/narrow.dart';
import '../model/realm.dart';
import 'actions.dart';
import 'button.dart';
import 'color.dart';
Expand Down Expand Up @@ -633,20 +634,21 @@ class UnsubscribeButton extends ActionSheetMenuItemButton {

@override
void onPressed() async {
final subscription = PerAccountStoreWidget.of(pageContext).subscriptions[channelId];
final store = PerAccountStoreWidget.of(pageContext);
final subscription = store.subscriptions[channelId];
if (subscription == null) return; // TODO could give feedback

// TODO(#1786) check group-based permission to subscribe, then replace
// error message with a new one saying "will not" instead of "might not"
// TODO(future) check if the self-user is a guest and the channel is not web-public
final couldResubscribe = !subscription.inviteOnly;
final couldResubscribe = !subscription.inviteOnly
|| store.selfHasPermissionForGroupSetting(subscription.canSubscribeGroup,
GroupSettingType.stream, 'can_subscribe_group');
if (!couldResubscribe) {
// TODO(#1788) warn if org would lose content access (nobody can subscribe)
final zulipLocalizations = ZulipLocalizations.of(pageContext);

final dialog = showSuggestedActionDialog(context: pageContext,
title: zulipLocalizations.unsubscribeConfirmationDialogTitle(subscription.name),
message: zulipLocalizations.unsubscribeConfirmationDialogMessageMaybeCannotResubscribe,
message: zulipLocalizations.unsubscribeConfirmationDialogMessageCannotResubscribe,
destructiveActionButton: true,
actionButtonText: zulipLocalizations.unsubscribeConfirmationDialogConfirmButton);
if (await dialog.result != true) return;
Expand Down
13 changes: 13 additions & 0 deletions test/model/test_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,19 @@ extension PerAccountStoreTestExtension on PerAccountStore {
await handleEvent(ChannelCreateEvent(id: 1, streams: streams));
}

Future<void> updateChannel(
int channelId,
ChannelPropertyName property,
Object? value,
) async {
await handleEvent(ChannelUpdateEvent(
id: 1,
streamId: channelId,
name: 'some channel name', // (not true, of course, but that's fine)
property: property,
value: value));
}

Future<void> addSubscription(Subscription subscription) async {
await addSubscriptions([subscription]);
}
Expand Down
20 changes: 18 additions & 2 deletions test/widgets/action_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,30 @@ void main() {
await tester.pump(); // [MenuItemButton.onPressed] called in a post-frame callback: flutter/flutter@e4a39fa2e
}

testWidgets('channel not subscribed', (tester) async {
testWidgets('channel not subscribed, with content access', (tester) async {
await prepare();
final narrow = ChannelNarrow(someChannel.streamId);
await store.removeSubscription(narrow.streamId);
check(store.selfHasContentAccess(someChannel)).isTrue();
await showFromMsglistAppBar(tester, narrow: narrow);
checkButton('Subscribe');
});

testWidgets('channel not subscribed, without content access', (tester) async {
final privateChannel = eg.stream(inviteOnly: true);
await prepare();
await store.addStream(privateChannel);
await store.updateChannel(privateChannel.streamId,
ChannelPropertyName.canSubscribeGroup, eg.groupSetting(members: []));
await store.updateChannel(privateChannel.streamId,
ChannelPropertyName.canAddSubscribersGroup, eg.groupSetting(members: []));
final narrow = ChannelNarrow(privateChannel.streamId);
check(store.selfHasContentAccess(privateChannel)).isFalse();
await showFromMsglistAppBar(tester,
channel: privateChannel, narrow: narrow);
checkNoButton('Subscribe');
});

testWidgets('channel subscribed', (tester) async {
await prepare();
final narrow = ChannelNarrow(someChannel.streamId);
Expand Down Expand Up @@ -584,7 +600,7 @@ void main() {

final (unsubscribeButton, cancelButton) = checkSuggestedActionDialog(tester,
expectedTitle: 'Unsubscribe from ${channel.name}?',
expectedMessage: 'Once you leave this channel, you might not be able to rejoin.',
expectedMessage: 'Once you leave this channel, you will not be able to rejoin.',
expectDestructiveActionButton: true,
expectedActionButtonText: 'Unsubscribe');
await tester.tap(find.byWidget(unsubscribeButton));
Expand Down