Skip to content

Commit

Permalink
92 add a button that temporarily disables automatic restoration of vi…
Browse files Browse the repository at this point in the history
…ewing sessions only current tab (#100)

* add button temporarily disable restore watching

* localize

* lint

---------

Co-authored-by: Tachibana Shin <[email protected]>
  • Loading branch information
tachibana-shin and tachib-akiko authored Apr 18, 2023
1 parent 6395a09 commit 2b18c8a
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 10 deletions.
7 changes: 7 additions & 0 deletions src/components/BrtPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ import type {
import { useAuthStore } from "stores/auth"
import { useHistoryStore } from "stores/history"
import { useSettingsStore } from "stores/settings"
import { useStateStorageStore } from "stores/state-storage"
import {
computed,
onBeforeUnmount,
Expand All @@ -1038,6 +1039,7 @@ const { t } = useI18n()
const authStore = useAuthStore()
const settingsStore = useSettingsStore()
const historyStore = useHistoryStore()
const stateStorageStore = useStateStorageStore()
const router = useRouter()
const $q = useQuasar()
Expand Down Expand Up @@ -1239,6 +1241,11 @@ watch(
try {
console.log(":restore progress")
if (stateStorageStore.disableAutoRestoration) {
addNotice(t("bo-qua-khoi-phuc-tien-trinh-xem"))
// eslint-disable-next-line functional/no-throw-statement
throw new Error("NOT_RESET")
}
const cur = (
await historyStore.getProgressChap(currentSeason, currentChap)
)?.cur
Expand Down
60 changes: 50 additions & 10 deletions src/components/FragmentChaps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,54 @@
<div class="py-1 px-4 text-subtitle1 flex items-center justify-between">
{{ gridModeTabsSeasons ? t("chon-season") : t("chon-tap") }}

<q-btn dense round @click="gridModeTabsSeasons = !gridModeTabsSeasons">
<Icon
:icon="
gridModeTabsSeasons
? 'fluent:grid-kanban-20-regular'
: 'fluent:apps-list-24-regular'
<div>
<q-btn
dense
round
@click="
stateStorageStore.disableAutoRestoration =
!stateStorageStore.disableAutoRestoration
"
width="20"
height="20"
/>
</q-btn>
:class="
stateStorageStore.disableAutoRestoration ? 'text-deep-orange-13' : ''
"
>
<Icon
:icon="
stateStorageStore.disableAutoRestoration
? 'fluent:arrow-sync-off-20-regular'
: 'fluent:arrow-sync-24-regular'
"
width="20"
height="20"
/>

<q-tooltip
anchor="bottom middle"
self="top middle"
class="text-14px max-w-150px"
:delay="1000"
>{{
stateStorageStore.disableAutoRestoration
? t("kich-hoat-lai-khoi-phuc-tien-trinh-xem")
: t(
"vo-hieu-hoa-tam-thoi-khoi-phuc-tien-trinh-xem-truoc-tam-thoi"
)
}}</q-tooltip
>
</q-btn>
<q-btn dense round @click="gridModeTabsSeasons = !gridModeTabsSeasons">
<Icon
:icon="
gridModeTabsSeasons
? 'fluent:grid-kanban-20-regular'
: 'fluent:apps-list-24-regular'
"
width="20"
height="20"
/>
</q-btn>
</div>
</div>

<div v-if="!seasons" class="flex-1 flex items-center justify-center">
Expand Down Expand Up @@ -107,6 +144,7 @@ import type {
ProgressWatchStore,
Season,
} from "src/pages/phim/_season.interface"
import { useStateStorageStore } from "src/stores/state-storage"
import { ref, watch, watchEffect } from "vue"
import { useI18n } from "vue-i18n"
Expand All @@ -131,6 +169,8 @@ const props = defineProps<{
}>()
const { t } = useI18n()
const stateStorageStore = useStateStorageStore()
const seasonActive = ref<string>()
// sync data by active route
watch(
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/messages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"bat-tieng-m": "Unmute (m)",
"bay-gio-_value": "Now {0}",
"binh-luan": "Comment",
"bo-qua-khoi-phuc-tien-trinh-xem": "Skip restore watch progress",
"cai-dat": "Setting",
"cai-dat-chung": "General settings",
"cai-dat-extension-animevsub-helper": "Install extension AnimeVsub Helper",
Expand Down Expand Up @@ -113,6 +114,7 @@
"khieu-nai-vi-pham": "Complaint of violation",
"khong-co-danh-sach-phat-nao": "No playlists yet",
"khong-co-thong-bao-moi-nao": "No new announcements",
"kich-hoat-lai-khoi-phuc-tien-trinh-xem": "Re-enable watch progress recovery",
"kiem-tra-cap-nhat": "Check for updates",
"la-mot-vpn-mien-phi": "is a free VPN",
"lich-chieu": "Showtimes",
Expand Down Expand Up @@ -225,6 +227,7 @@
"ve-chung-toi": "About us",
"ve-ung-dung": "About the app",
"video-tam-thoi-khong-kha-dung": "Video is temporarily unavailable",
"vo-hieu-hoa-tam-thoi-khoi-phuc-tien-trinh-xem-truoc-tam-thoi": "Temporarily disable restoring preview progress (temporarily)",
"voi": "with",
"vui-long-thu-cap-nhat-extension-neu-su-co-khong-duoc-khac-phuc-vui-long-gui-email-den": "Please try updating the extension, if the problem is not fixed please email to",
"xac-nhan": "Confirm",
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/messages/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"bat-tieng-m": "ミュート解除 (分)",
"bay-gio-_value": "現在{0}",
"binh-luan": "コメント",
"bo-qua-khoi-phuc-tien-trinh-xem": "復元ウォッチの進行状況をスキップ",
"cai-dat": "設定",
"cai-dat-chung": "一般設定",
"cai-dat-extension-animevsub-helper": "拡張機能 AnimeVsub Helper をインストールする",
Expand Down Expand Up @@ -113,6 +114,7 @@
"khieu-nai-vi-pham": "違反の苦情",
"khong-co-danh-sach-phat-nao": "プレイリストはまだありません",
"khong-co-thong-bao-moi-nao": "新しい発表はありません",
"kich-hoat-lai-khoi-phuc-tien-trinh-xem": "時計の進行状況の回復を再度有効にする",
"kiem-tra-cap-nhat": "アップデートを確認",
"la-mot-vpn-mien-phi": "無料のVPNです",
"lich-chieu": "上映時間",
Expand Down Expand Up @@ -225,6 +227,7 @@
"ve-chung-toi": "私たちに関しては",
"ve-ung-dung": "アプリについて",
"video-tam-thoi-khong-kha-dung": "動画は一時的に利用できません",
"vo-hieu-hoa-tam-thoi-khoi-phuc-tien-trinh-xem-truoc-tam-thoi": "プレビューの進行状況の復元を一時的に無効にする (一時的に)",
"voi": "",
"vui-long-thu-cap-nhat-extension-neu-su-co-khong-duoc-khac-phuc-vui-long-gui-email-den": "拡張機能を更新してみてください。問題が解決しない場合は、にメールしてください。",
"xac-nhan": "確認",
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/messages/vi-VN.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"bat-tieng-m": "Bật tiếng (m)",
"bay-gio-_value": "Bây giờ {0}",
"binh-luan": "Bình luận",
"bo-qua-khoi-phuc-tien-trinh-xem": "Bỏ qua khôi phục tiến trình xem",
"cai-dat": "Cài đặt",
"cai-dat-chung": "Cài đặt chung",
"cai-dat-extension-animevsub-helper": "Cài đặt extension AnimeVsub Helper",
Expand Down Expand Up @@ -113,6 +114,7 @@
"khieu-nai-vi-pham": "Khiếu nại vi phạm",
"khong-co-danh-sach-phat-nao": "Không có danh sách phát nào",
"khong-co-thong-bao-moi-nao": "Không có thông báo mới nào",
"kich-hoat-lai-khoi-phuc-tien-trinh-xem": "Kích hoạt lại khôi phục tiến trình xem",
"kiem-tra-cap-nhat": "Kiểm tra cập nhật",
"la-mot-vpn-mien-phi": "là một VPN miễn phí",
"lich-chieu": "Lịch chiếu",
Expand Down Expand Up @@ -225,6 +227,7 @@
"ve-chung-toi": "Về chúng tôi",
"ve-ung-dung": "Về ứng dụng",
"video-tam-thoi-khong-kha-dung": "Video tạm thời không khả dụng",
"vo-hieu-hoa-tam-thoi-khoi-phuc-tien-trinh-xem-truoc-tam-thoi": "Vô hiệu hóa tạm thời khôi phục tiến trình xem trước (tạm thời)",
"voi": "với",
"vui-long-thu-cap-nhat-extension-neu-su-co-khong-duoc-khac-phuc-vui-long-gui-email-den": "Vui lòng thử cập nhật extension, nếu sự cố không được khắc phục vui lòng gửi email đến",
"xac-nhan": "Xác nhận",
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/messages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"bat-tieng-m": "取消静音 (m)",
"bay-gio-_value": "现在{0}",
"binh-luan": "评论",
"bo-qua-khoi-phuc-tien-trinh-xem": "跳过恢复观看进度",
"cai-dat": "环境",
"cai-dat-chung": "通用设置",
"cai-dat-extension-animevsub-helper": "安装扩展 AnimeVsub Helper",
Expand Down Expand Up @@ -113,6 +114,7 @@
"khieu-nai-vi-pham": "违规投诉",
"khong-co-danh-sach-phat-nao": "还没有播放列表",
"khong-co-thong-bao-moi-nao": "没有新的公告",
"kich-hoat-lai-khoi-phuc-tien-trinh-xem": "重新启用观看进度恢复",
"kiem-tra-cap-nhat": "检查更新",
"la-mot-vpn-mien-phi": "是一个免费的VPN",
"lich-chieu": "放映时间",
Expand Down Expand Up @@ -225,6 +227,7 @@
"ve-chung-toi": "关于我们",
"ve-ung-dung": "关于应用程序",
"video-tam-thoi-khong-kha-dung": "视频暂时不可用",
"vo-hieu-hoa-tam-thoi-khoi-phuc-tien-trinh-xem-truoc-tam-thoi": "暂时禁用恢复预览进度(暂时)",
"voi": "",
"vui-long-thu-cap-nhat-extension-neu-su-co-khong-duoc-khac-phuc-vui-long-gui-email-den": "请尝试更新扩展程序,如果问题未解决,请发送电子邮件至",
"xac-nhan": "确认",
Expand Down
9 changes: 9 additions & 0 deletions src/stores/state-storage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineStore } from "pinia";
import { ref } from "vue";

export const useStateStorageStore =
defineStore("state-storage", () => {
const disableAutoRestoration = ref(false)

return { disableAutoRestoration }
})

0 comments on commit 2b18c8a

Please sign in to comment.