From 2526940f71b7b99a3c79c69ad077ad9475385cd5 Mon Sep 17 00:00:00 2001 From: TaYaKi71751 Date: Wed, 10 Jan 2024 10:54:11 +0900 Subject: [PATCH 1/4] Add showToast in exportbookmarkgit --- lib/pages/settings/settings_page.dart | 46 ++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/lib/pages/settings/settings_page.dart b/lib/pages/settings/settings_page.dart index f9183edf0..3bdf99c5c 100644 --- a/lib/pages/settings/settings_page.dart +++ b/lib/pages/settings/settings_page.dart @@ -2022,17 +2022,47 @@ class _SettingsPageState extends State if (await Directory(gitPath).exists()) { await Directory(gitPath).delete(recursive: true); } - - final git = BookmarkGit(); - await git.clone(gitPath); - final extpath = '$gitPath/bookmark.db'; - await bookmarkDatabaseFile.copy(extpath); - await git.addAll(gitPath); - await git.commit(gitPath); - await git.push(gitPath); + try { + final git = BookmarkGit(); + await git.clone(gitPath); + final extpath = '$gitPath/bookmark.db'; + await bookmarkDatabaseFile.copy(extpath); + await git.addAll(gitPath); + await git.commit(gitPath); + await git.push(gitPath); + } catch(e,st){ + Logger.error('[exportingbookmarkgit] $e\n' + '$st'); + flutterToast.showToast( + child: ToastWrapper( + isCheck: true, + isWarning: false, + msg: Translations.of(context) + .trans('failexportbookmark'), + ), + ignorePointer: true, + gravity: ToastGravity.BOTTOM, + toastDuration: const Duration(seconds: 4), + ); + if (await Directory(gitPath).exists()) { + await Directory(gitPath).delete(recursive: true); + } + return; + } if (await Directory(gitPath).exists()) { await Directory(gitPath).delete(recursive: true); } + flutterToast.showToast( + child: ToastWrapper( + isCheck: true, + isWarning: false, + msg: Translations.of(context) + .trans('exportbookmark'), + ), + ignorePointer: true, + gravity: ToastGravity.BOTTOM, + toastDuration: const Duration(seconds: 4), + ); }, ), InkWell( From 4b742dd7958bab27737e9c3dc94854dd9015bae5 Mon Sep 17 00:00:00 2001 From: TaYaKi71751 Date: Wed, 10 Jan 2024 10:58:58 +0900 Subject: [PATCH 2/4] Add locale for exportingbookmarkgit --- assets/locale/en.json | 1 + assets/locale/eo.json | 1 + assets/locale/it.json | 1 + assets/locale/ja.json | 1 + assets/locale/ko.json | 1 + assets/locale/pt.json | 1 + assets/locale/zh.json | 1 + assets/locale/zh_Hans.json | 1 + assets/locale/zh_Hant.json | 1 + 9 files changed, 9 insertions(+) diff --git a/assets/locale/en.json b/assets/locale/en.json index c170c69c7..8ce2b0456 100644 --- a/assets/locale/en.json +++ b/assets/locale/en.json @@ -153,6 +153,7 @@ "importingbookmark": "Import Bookmark", "exportingbookmark": "Export Bookmark", "exportingbookmarkgit": "Export Bookmark to Git Repository", + "failexportbookmark": "Failed to export bookmark", "noauth": "You do not have permission to run it.", "noselectedb": "No database selected.", "importbookmark": "Bookmark Imported!", diff --git a/assets/locale/eo.json b/assets/locale/eo.json index e92aa48e1..20cca3884 100644 --- a/assets/locale/eo.json +++ b/assets/locale/eo.json @@ -153,6 +153,7 @@ "importingbookmark": "Importar Marcador", "exportingbookmark": "Exportar Marcador", "exportingbookmarkgit": "Export Bookmark to Git Repository", + "failexportbookmark": "Failed to export bookmark", "noauth": "No tienes permiso para iniciar.", "noselectedb": "No se ha seleccionado ninguna base de datos.", "importbookmark": "¡Marcador Importado!", diff --git a/assets/locale/it.json b/assets/locale/it.json index de93ef4d7..e84a02d6a 100644 --- a/assets/locale/it.json +++ b/assets/locale/it.json @@ -153,6 +153,7 @@ "importingbookmark": "Importa Segnalibri", "exportingbookmark": "Esporta Segnalibri", "exportingbookmarkgit": "Export Bookmark to Git Repository", + "failexportbookmark": "Failed to export bookmark", "noauth": "Non hai il permesso di avviarlo.", "noselectedb": "Nessun database selezionato.", "importbookmark": "Segnalibri Importati!", diff --git a/assets/locale/ja.json b/assets/locale/ja.json index edb00568a..420aed767 100644 --- a/assets/locale/ja.json +++ b/assets/locale/ja.json @@ -153,6 +153,7 @@ "importingbookmark": "ブックマークを読み込む", "exportingbookmark": "ブックマークの書き出す", "exportingbookmarkgit": "Export Bookmark to Git Repository", + "failexportbookmark": "Failed to export bookmark", "noauth": "権限がないため、実行できません。", "noselectedb": "選択されたデータベースがありません。", "importbookmark": "ブックマークを読み込みしました!", diff --git a/assets/locale/ko.json b/assets/locale/ko.json index c0de5d734..ad177e090 100644 --- a/assets/locale/ko.json +++ b/assets/locale/ko.json @@ -153,6 +153,7 @@ "importingbookmark": "북마크 가져오기", "exportingbookmark": "북마크 내보내기", "exportingbookmarkgit": "Export Bookmark to Git Repository", + "failexportbookmark": "Failed to export bookmark", "noauth": "권한이 없어서 실행할 수 없습니다.", "noselectedb": "선택된 데이터베이스가 없습니다.", "importbookmark": "북마크를 가져왔습니다!", diff --git a/assets/locale/pt.json b/assets/locale/pt.json index f53f84b62..ea141b444 100644 --- a/assets/locale/pt.json +++ b/assets/locale/pt.json @@ -153,6 +153,7 @@ "importingbookmark": "Importar marcador", "exportingbookmark": "Exportar marcador", "exportingbookmarkgit": "Export Bookmark to Git Repository", + "failexportbookmark": "Failed to export bookmark", "noauth": "Você não tem permissão para executar isso.", "noselectedb": "Nenhum banco de dados selecionado.", "importbookmark": "Marcador importado!", diff --git a/assets/locale/zh.json b/assets/locale/zh.json index 68018e8fc..96a4183c1 100644 --- a/assets/locale/zh.json +++ b/assets/locale/zh.json @@ -153,6 +153,7 @@ "importingbookmark": "Import Bookmark", "exportingbookmark": "Export Bookmark", "exportingbookmarkgit": "Export Bookmark to Git Repository", + "failexportbookmark": "Failed to export bookmark", "noauth": "You do not have permission to run it.", "noselectedb": "No database selected.", "importbookmark": "Bookmark Imported!", diff --git a/assets/locale/zh_Hans.json b/assets/locale/zh_Hans.json index 352fd23cf..d4e5e03d9 100644 --- a/assets/locale/zh_Hans.json +++ b/assets/locale/zh_Hans.json @@ -153,6 +153,7 @@ "importingbookmark": "导入书签", "exportingbookmark": "导出书签", "exportingbookmarkgit": "Export Bookmark to Git Repository", + "failexportbookmark": "Failed to export bookmark", "noauth": "你没有权限执行此操作.", "noselectedb": "没有数据库被选中.", "importbookmark": "书签导入成功!", diff --git a/assets/locale/zh_Hant.json b/assets/locale/zh_Hant.json index 256cf32d8..623a79c41 100644 --- a/assets/locale/zh_Hant.json +++ b/assets/locale/zh_Hant.json @@ -153,6 +153,7 @@ "importingbookmark": "Import Bookmark", "exportingbookmark": "Export Bookmark", "exportingbookmarkgit": "Export Bookmark to Git Repository", + "failexportbookmark": "Failed to export bookmark", "noauth": "You do not have permission to run it.", "noselectedb": "No database selected.", "importbookmark": "Bookmark Imported!", From aedf969cb564d0629ec4ed003b0cc144fc9932be Mon Sep 17 00:00:00 2001 From: TaYaKi71751 Date: Wed, 10 Jan 2024 11:03:45 +0900 Subject: [PATCH 3/4] Dart Format --- lib/pages/settings/settings_page.dart | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/pages/settings/settings_page.dart b/lib/pages/settings/settings_page.dart index 3bdf99c5c..69b49d29e 100644 --- a/lib/pages/settings/settings_page.dart +++ b/lib/pages/settings/settings_page.dart @@ -2030,15 +2030,14 @@ class _SettingsPageState extends State await git.addAll(gitPath); await git.commit(gitPath); await git.push(gitPath); - } catch(e,st){ + } catch (e, st) { Logger.error('[exportingbookmarkgit] $e\n' - '$st'); + '$st'); flutterToast.showToast( child: ToastWrapper( isCheck: true, isWarning: false, - msg: Translations.of(context) - .trans('failexportbookmark'), + msg: Translations.of(context).trans('failexportbookmark'), ), ignorePointer: true, gravity: ToastGravity.BOTTOM, @@ -2056,8 +2055,7 @@ class _SettingsPageState extends State child: ToastWrapper( isCheck: true, isWarning: false, - msg: Translations.of(context) - .trans('exportbookmark'), + msg: Translations.of(context).trans('exportbookmark'), ), ignorePointer: true, gravity: ToastGravity.BOTTOM, From 6df6491a1c84cedddb8287f619f3030f32300476 Mon Sep 17 00:00:00 2001 From: TaYaKi71751 Date: Wed, 10 Jan 2024 14:46:44 +0900 Subject: [PATCH 4/4] Fix first to last for recent added --- lib/pages/settings/settings_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/settings/settings_page.dart b/lib/pages/settings/settings_page.dart index 69b49d29e..5c98b040a 100644 --- a/lib/pages/settings/settings_page.dart +++ b/lib/pages/settings/settings_page.dart @@ -2133,7 +2133,7 @@ class _SettingsPageState extends State element.description() == description && // element.color() == color.value && DateTime.tryParse(element.datetime()) == datetime)) - .first + .last .id(); for (int j = 0; j <