Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

いくつかの修正など #693

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions lib/l10n/app_ja-oj.arb
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,31 @@
"thrownError": "なにか様子がおかしいですわね…",

"exportedFileNotFound": "ここにMiriaの設定ファイル見つかりませんでしたわよ",
"importCompleted": "インポート終わりましたわ",
"importCompleted": "インポート終わりましたわ",
"confirmOverwrite": "ここにもうあるようですけれど……上書きいたしますの?",
"exportCompleted": "エクスポート終わりましたわ",

"pleaseInputSomething": "なにか入れてくださいまし?",
"pleaseAddVoteChoice": "投票の選択肢を2つ以上入れてくださまいし?",
"pleaseAddVoteChoice": "投票の選択肢を2つ以上入れてくださいまし?",
"pleaseSpecifyExpirationDate": "投票がいつまでか入れてくださいまし?",
"pleaseSpecifyExpirationDuration": "投票期間を入れてくださいまし?",
"cannotMentionToRemoteInLocalOnlyNote": "連合切られているのに他のサーバーの人がメンションに含まれているようですわ",
"cannotPublicReplyToPrivateNote": "リプライが{visibility}のようでして……パブリックにはできませんこと",

"unexpectedSensitive": "上げようとしたファイルがサーバーから、センシティブと思われたようですわね",
"staySensitive": "センシティブのままにしますわ",

"memoDescription": "メモしたいことをお書きくださいまし",
"confirmCreateBlock": "ブロックなさりますの?",
"confirmUnfollow": "フォロー解除なさりますの?",

"unsupportedFile": "対応してないファイルのようですわ",
"unsupportedFileWithFilename": "{filename}は対応してないファイルのようですわ",
"failedFileSave": "ファイルの保存に失敗したようですわね…",

"invitedReversi": "{users}から招待されているようですわ",
"nonInvitedReversi": "招待されていないようですわね…",

"nothingHere": "ここには何もありませんわ"


Expand Down
7 changes: 7 additions & 0 deletions lib/l10n/app_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,13 @@

"unsupportedFile": "対応してないファイルやわ",
"unsupportedFileWithFilename": "{filename}は対応してないファイルやわ",
"@unsupportedFileWithFilename": {
"placeholders": {
"filename": {
"type": "String"
}
}
},
"failedFileSave": "ファイルの保存に失敗したみたいや",

"misskeyGames": "Misskey Games",
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ class Miria extends HookConsumerWidget with WidgetsBindingObserver {
GlobalCupertinoLocalizations.delegate,
],
builder: (context, widget) {
return DialogScope(
child: AppThemeScope(
return AppThemeScope(
child: DialogScope(
child: SharingIntentListener(
router: appRouter,
child: ErrorDialogListener(
Expand Down
86 changes: 52 additions & 34 deletions lib/repository/import_export_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import "package:miria/model/exported_setting.dart";
import "package:miria/model/tab_setting.dart";
import "package:miria/providers.dart";
import "package:miria/router/app_router.dart";
import "package:miria/view/common/modal_indicator.dart";
import "package:miria/view/dialogs/simple_confirm_dialog.dart";
import "package:miria/view/dialogs/simple_message_dialog.dart";
import "package:miria/view/settings_page/import_export_page/folder_select_dialog.dart";
Expand Down Expand Up @@ -68,41 +69,50 @@ class ImportExportRepository extends ChangeNotifier {
}

final importFile = alreadyExists.sortedBy((file) => file.createdAt).last;
try {
IndicatorView.showIndicator(context);

final response = await reader(dioProvider)
.get(importFile.url, options: Options(responseType: ResponseType.json));
final response = await reader(dioProvider).get(importFile.url,
options: Options(responseType: ResponseType.json));

final json = jsonDecode(response.data);
final json = jsonDecode(response.data);

final importedSettings = ExportedSetting.fromJson(json);
final importedSettings = ExportedSetting.fromJson(json);

// アカウント設定よみこみ
final accounts = reader(accountsProvider);
for (final accountSetting in importedSettings.accountSettings) {
// この端末でログイン済みのアカウントであれば
if (accounts.any((account) => account.acct == accountSetting.acct)) {
await reader(accountSettingsRepositoryProvider).save(accountSetting);
// アカウント設定よみこみ
final accounts = reader(accountsProvider);
for (final accountSetting in importedSettings.accountSettings) {
// この端末でログイン済みのアカウントであれば
if (accounts.any((account) => account.acct == accountSetting.acct)) {
await reader(accountSettingsRepositoryProvider).save(accountSetting);
}
}
}

// 全般設定
await reader(generalSettingsRepositoryProvider)
.update(importedSettings.generalSettings);
// 全般設定
await reader(generalSettingsRepositoryProvider)
.update(importedSettings.generalSettings);

// タブ設定
final tabSettings = <TabSetting>[];
// タブ設定
final tabSettings = <TabSetting>[];

for (final tabSetting in importedSettings.tabSettings) {
final account = accounts
.firstWhereOrNull((account) => tabSetting.acct == account.acct);
for (final tabSetting in importedSettings.tabSettings) {
final account = accounts
.firstWhereOrNull((account) => tabSetting.acct == account.acct);

if (account == null) {
continue;
}
if (account == null) {
continue;
}

tabSettings.add(tabSetting);
tabSettings.add(tabSetting);
}
await reader(tabSettingsRepositoryProvider).save(tabSettings);
} catch (e) {
rethrow;
} finally {
if (context.mounted) {
IndicatorView.hideIndicator(context);
}
}
await reader(tabSettingsRepositoryProvider).save(tabSettings);

if (!context.mounted) return;
await SimpleMessageDialog.show(context, S.of(context).importCompleted);
Expand Down Expand Up @@ -163,16 +173,24 @@ class ImportExportRepository extends ChangeNotifier {
};

if (!context.mounted) return;
await reader(misskeyProvider(account)).drive.files.createAsBinary(
DriveFilesCreateRequest(
folderId: folder?.id,
name: "miria.json",
comment: S.of(context).exportedFileComment,
force: true,
),
Uint8List.fromList(utf8.encode(jsonEncode(data))),
);

try {
IndicatorView.showIndicator(context);
await reader(misskeyProvider(account)).drive.files.createAsBinary(
DriveFilesCreateRequest(
folderId: folder?.id,
name: "miria.json",
comment: S.of(context).exportedFileComment,
force: true,
),
Uint8List.fromList(utf8.encode(jsonEncode(data))),
);
} catch (e) {
rethrow;
} finally {
if (context.mounted) {
IndicatorView.hideIndicator(context);
}
}
if (!context.mounted) return;
await SimpleMessageDialog.show(context, S.of(context).exportCompleted);
}
Expand Down
21 changes: 17 additions & 4 deletions lib/router/app_router.gr.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class MisskeyNoteNotifier extends _$MisskeyNoteNotifier {
await navigateToNoteDetailPage(note, account: selectedAccount);
}

Future<void> openUserInOtherAccount(User user) async {
Future<void> openUserInOtherAccount(User user, String? host) async {
final accountContext = ref.read(accountContextProvider);
final selectedAccount = await ref.read(appRouterProvider).push<Account>(
AccountSelectRoute(
Expand All @@ -203,6 +203,21 @@ class MisskeyNoteNotifier extends _$MisskeyNoteNotifier {
);

if (selectedAccount == null) return;
if (user.host == null) {
switch (user) {
case UserLite():
user = user.copyWith(host: host ?? accountContext.getAccount.host);

case UserDetailedNotMe():
user = user.copyWith(host: host ?? accountContext.getAccount.host);

case UserDetailedNotMeWithRelations():
user = user.copyWith(host: host ?? accountContext.getAccount.host);

case MeDetailed():
user = user.copyWith(host: host ?? accountContext.getAccount.host);
}
}
await navigateToUserPage(user, account: selectedAccount);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions lib/view/common/account_select_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ import "package:miria/view/common/misskey_notes/mfm_text.dart";

@RoutePage<Account>()
class AccountSelectDialog extends HookConsumerWidget {
const AccountSelectDialog({super.key, this.host, this.remoteHost});
const AccountSelectDialog({
super.key,
this.host,
this.remoteHost,
this.showWithoutLogin = true,
});

/// nullではないとき, 指定されたサーバーのアカウントのみ表示する
final String? host;

/// 相手先のホスト
final String? remoteHost;

// 相手先のサーバで開く(ログインなし)を表示
final bool showWithoutLogin;

@override
Widget build(BuildContext context, WidgetRef ref) {
final accounts = ref.watch(accountsProvider);
Expand All @@ -41,7 +49,7 @@ class AccountSelectDialog extends HookConsumerWidget {
height: MediaQuery.of(context).size.height * 0.8,
child: ListView(
children: [
if (remoteHost != null)
if (showWithoutLogin && remoteHost != null)
switch (navigateAsRemote.value) {
AsyncLoading() => const Center(
child: CircularProgressIndicator.adaptive(),
Expand Down
6 changes: 5 additions & 1 deletion lib/view/common/misskey_notes/link_navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ class LinkNavigator {
);
} else if (uri.pathSegments.length == 1 &&
uri.pathSegments.first.startsWith("@")) {
await onMentionTap(context, ref, uri.pathSegments.first, host);
final userName = ("@".allMatches(uri.pathSegments.first).length == 1)
? "${uri.pathSegments.first}@${uri.host}"
: uri.pathSegments.first;

await onMentionTap(context, ref, userName, host);
} else {
if (await canLaunchUrl(uri)) {
await launchUrl(uri, mode: LaunchMode.externalApplication);
Expand Down
1 change: 1 addition & 0 deletions lib/view/common/misskey_notes/renote_modal_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class RenoteOtherAccountNotifier extends _$RenoteOtherAccountNotifier {
note.user.host != this.account.host && note.user.host != null
? note.user.host
: null,
showWithoutLogin: false,
),
);
if (selectedAccount == null) return;
Expand Down
2 changes: 1 addition & 1 deletion lib/view/common/misskey_notes/renote_modal_sheet.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/view/common/note_file_dialog/image_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ class ImageViewer extends HookConsumerWidget {
},
onDoubleTap: () {
if (provider.scale != 1.0) {
resetScale();
if (provider.scale == provider.lastScale) {
resetScale();
}
} else {
final position = ref
.read(imageViewerInfoNotifierProvider)
Expand Down
Loading
Loading