Skip to content

Commit

Permalink
refactor: use query.id in favor of route hash
Browse files Browse the repository at this point in the history
  • Loading branch information
darwintree committed Jan 9, 2025
1 parent bb48ba2 commit 174a6b8
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 11 deletions.
2 changes: 2 additions & 0 deletions TODOs.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
- [ ] web push
- [x] load setting: if specified a json path, priority to load localstorage history
- [x] remind user if to history mode
- [ ] comments(giscus)
- [ ] splitted story comments and translation comments

### Improvements

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"start": "vite",
"start": "make prebuild && vite",
"serve:doc": "honkit serve --reload",
"build:doc": "honkit build",
"build": "make prebuild && vue-tsc && vite build && honkit build",
Expand Down
3 changes: 2 additions & 1 deletion src/components/bgm/BgmPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ const createColumns = (): any => {
query: {
forceReload: '1',
source: DataSource.Remote,
id: row.jsonPath,
},
hash: `#${row.jsonPath}`,
// hash: `#${row.jsonPath}`,
})
}
const style = {
Expand Down
3 changes: 2 additions & 1 deletion src/components/home/HistorySaves.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ const columns = ref(
query: {
forceReload: '1',
source: DataSource.Browser,
id: row.id,
},
// do not use encodeURIComponent
hash: `#${row.id}`,
// hash: `#${row.id}`,
})
},
})
Expand Down
3 changes: 2 additions & 1 deletion src/components/list/ListPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ const createColumns = (): any => {
query: {
forceReload: '1',
source: DataSource.Remote,
id: row.communications[0].jsonPath,
},
// do not use encodeURIComponent
hash: `#${row.communications[0].jsonPath}`,
// hash: `#${row.communications[0].jsonPath}`,
})
}
style = {
Expand Down
3 changes: 2 additions & 1 deletion src/components/search/VoiceSearchPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ const createColumns = (): any => {
query: {
forceReload: '1',
source: DataSource.Remote,
id: getEventIdFromVoiceId(row._id),
},
// do not use encodeURIComponent
hash: `#${getEventIdFromVoiceId(row._id)}`,
// hash: `#${getEventIdFromVoiceId(row._id)}`,
})
}
const style = {
Expand Down
3 changes: 2 additions & 1 deletion src/components/translate/CommunicationLogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ export default defineComponent({
query: {
forceReload: '1',
source: DataSource.Remote,
id: url,
},
hash: `#${url}`,
// hash: `#${url}`,
})
},
style: {
Expand Down
3 changes: 2 additions & 1 deletion src/components/translate/DialogueLine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,10 @@ export default defineComponent({
store.currentMode = DataMode.History
this.$router.replace({
path: this.$route.path,
hash: `#${this.base}.json`, // for file mode
// hash: `#${this.base}.json`, // for file mode
query: {
source: DataSource.Browser,
id: `${this.base}.json`,
},
})
},
Expand Down
11 changes: 7 additions & 4 deletions src/components/translate/TranslationPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ watch(routeQuery, async (newQuery) => {
})
async function loadDataFromLocation() {
if (!route.hash) return
const source = route.query?.source as DataSource | undefined
// storage id, should be jsonUrl
const id = route.hash.substring(1)
const id = (route.query?.id || route.hash.substring(1)) as string
if (!id) return
if (source === DataSource.Browser) {
// store.currentMode = DataMode.History
// why push, use replace is also ok
Expand Down Expand Up @@ -173,6 +173,7 @@ async function loadDataFromLocalStorage(id: string) {
path: route.path,
query: {
source: DataSource.Browser,
id: route.query.id,
},
hash: route.hash,
})
Expand All @@ -190,9 +191,10 @@ async function loadDataFromEncodedUrl(encodedSrcUrl: string) {
)
router.replace({
path: route.path,
hash: `#${encodedSrcUrl}`,
// hash: `#${encodedSrcUrl}`,
query: {
source: DataSource.Remote,
id: encodedSrcUrl,
},
})
nextTick(() =>
Expand Down Expand Up @@ -232,8 +234,9 @@ async function to(source: DataSource | undefined, id: string) {
query: {
source,
forceReload: '1',
id,
},
hash: `#${id}`,
// hash: `#${id}`,
})
}
Expand Down

0 comments on commit 174a6b8

Please sign in to comment.