From 85becd34a098febf1b9e98b6796d2d8e1ac7b0f3 Mon Sep 17 00:00:00 2001 From: Appbird Date: Thu, 2 Sep 2021 23:01:39 +0900 Subject: [PATCH 1/5] =?UTF-8?q?history.pushState()=E3=81=AB=E3=81=A6state?= =?UTF-8?q?=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88=E3=81=AB?= =?UTF-8?q?requiredObj=E3=81=AE=E6=83=85=E5=A0=B1=E3=82=92=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ts/client/Administrator/HistoryAdministrator.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ts/client/Administrator/HistoryAdministrator.ts b/src/ts/client/Administrator/HistoryAdministrator.ts index 791c45c..935b16d 100644 --- a/src/ts/client/Administrator/HistoryAdministrator.ts +++ b/src/ts/client/Administrator/HistoryAdministrator.ts @@ -30,28 +30,29 @@ export class HistoryAdministrator{ return localStorage.getItem("KSSRs::HistoryAdministrator::clearIntroduction_v1") === "true" } registerCurrentPage(){ - localStorage.setItem("KSSRs::HistoryAdministrator::PreviousPage",JSON.stringify({ + const data = JSON.stringify({ pageState:this.app.state.state, requiredObject:this.app.state.requiredObj - })) + }) + localStorage.setItem("KSSRs::HistoryAdministrator::PreviousPage",data) switch(this.app.state.state){ case "detailView":{ const obj = this.app.state.requiredObj as APIFunctions["record_detail"]["atServer"] - history.pushState(null,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/ogpDetailView/?state=detailView&gs=${obj.gameSystemEnv.gameSystemID}&gm=${obj.gameSystemEnv.gameModeID}&id=${obj.id}`) + history.pushState(data,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/ogpDetailView/?state=detailView&gs=${obj.gameSystemEnv.gameSystemID}&gm=${obj.gameSystemEnv.gameModeID}&id=${obj.id}`) break; } case "userPageInWhole":{ const obj = this.app.state.requiredObj as {runnerID:string} - history.pushState(null,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/?state=userPageInWhole&id=${obj.runnerID}`) + history.pushState(data,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/?state=userPageInWhole&id=${obj.runnerID}`) break; } case "userPageInSpecific":{ const obj = this.app.state.requiredObj as TargetGameMode&{runnerID:string} - history.pushState(null,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/?state=userPageInWhole&id=${obj.runnerID}`) + history.pushState(data,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/?state=userPageInWhole&id=${obj.runnerID}`) break; } default: - history.pushState(null,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/`) + history.pushState(data,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/`) break; } From 1fcd530b1b05fc4be1ac99d2cf17bd00730b264c Mon Sep 17 00:00:00 2001 From: Appbird Date: Thu, 2 Sep 2021 23:03:38 +0900 Subject: [PATCH 2/5] =?UTF-8?q?transitionPile=E3=82=92=E5=BB=83=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/Administrator/HistoryAdministrator.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/ts/client/Administrator/HistoryAdministrator.ts b/src/ts/client/Administrator/HistoryAdministrator.ts index 935b16d..de9a458 100644 --- a/src/ts/client/Administrator/HistoryAdministrator.ts +++ b/src/ts/client/Administrator/HistoryAdministrator.ts @@ -7,21 +7,12 @@ import { LanguageInApplication } from "../../type/LanguageInApplication"; export class HistoryAdministrator{ private app:IAppUsedToReadAndChangePage; private urlAd:URLAdministrator - private transitionPile:TransitionItem[] = []; constructor(app:IAppUsedToReadAndChangePage){ this.app = app; this.urlAd = new URLAdministrator(app) window.addEventListener('popstate', (e) => { - this.back(); }); } - async appendHistory(){ - this.transitionPile.push({ - pageState:this.app.state.state, - requiredObject:this.app.state.requiredObj - }) - - } clearIntroduction(){ localStorage.setItem("KSSRs::HistoryAdministrator::clearIntroduction_v1","true") @@ -64,11 +55,6 @@ export class HistoryAdministrator{ console.info(`[KSSRs::HistoryAdministrator::TargetMode] register current target gamemode: ${this.app.state.gameSystemEnvDisplayed.gameSystem?.English} / ${this.app.state.gameSystemEnvDisplayed.gameMode?.Japanese}`) } - back(){ - const past = this.transitionPile.pop(); - if (past === undefined) return; - this.app.transition(past.pageState,past.requiredObject,{ifAppendHistory:false}) - } getPreviousPageData():TransitionItem|"redirect"|null{ const str = localStorage.getItem("KSSRs::HistoryAdministrator::PreviousPage") if (str === null) return null; From 193cb90f5b908d6ffbbb83f583f18d0f31e4ced1 Mon Sep 17 00:00:00 2001 From: Appbird Date: Thu, 2 Sep 2021 23:11:12 +0900 Subject: [PATCH 3/5] =?UTF-8?q?state=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=82=AF=E3=83=88=E3=82=92json=E6=96=87=E5=AD=97=E5=88=97?= =?UTF-8?q?=E3=81=A7=E3=81=AF=E3=81=AA=E3=81=8F=E3=81=9D=E3=81=AE=E3=81=BE?= =?UTF-8?q?=E3=81=BE=E3=81=AE=E3=83=87=E3=83=BC=E3=82=BF=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://developer.mozilla.org/ja/docs/Web/API/History_API/Working_with_the_History_API 履歴エントリのstateオブジェクトはコピーされるらしい。 --- src/ts/client/Administrator/HistoryAdministrator.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ts/client/Administrator/HistoryAdministrator.ts b/src/ts/client/Administrator/HistoryAdministrator.ts index de9a458..9dd0196 100644 --- a/src/ts/client/Administrator/HistoryAdministrator.ts +++ b/src/ts/client/Administrator/HistoryAdministrator.ts @@ -10,7 +10,8 @@ export class HistoryAdministrator{ constructor(app:IAppUsedToReadAndChangePage){ this.app = app; this.urlAd = new URLAdministrator(app) - window.addEventListener('popstate', (e) => { + window.addEventListener('popstate', (event) => { + }); } clearIntroduction(){ @@ -21,11 +22,11 @@ export class HistoryAdministrator{ return localStorage.getItem("KSSRs::HistoryAdministrator::clearIntroduction_v1") === "true" } registerCurrentPage(){ - const data = JSON.stringify({ + const data = { pageState:this.app.state.state, requiredObject:this.app.state.requiredObj - }) - localStorage.setItem("KSSRs::HistoryAdministrator::PreviousPage",data) + } + localStorage.setItem("KSSRs::HistoryAdministrator::PreviousPage",JSON.stringify(data)) switch(this.app.state.state){ case "detailView":{ const obj = this.app.state.requiredObj as APIFunctions["record_detail"]["atServer"] From 24feb1864802a051fb682369b807550d56c12310 Mon Sep 17 00:00:00 2001 From: Appbird Date: Thu, 2 Sep 2021 23:17:49 +0900 Subject: [PATCH 4/5] =?UTF-8?q?popstate=E3=81=95=E3=82=8C=E3=81=9F?= =?UTF-8?q?=E3=81=A8=E3=81=8D=E3=81=AB=E3=80=81=E5=B1=A5=E6=AD=B4=E3=82=A8?= =?UTF-8?q?=E3=83=B3=E3=83=88=E3=83=AA=E3=81=AE=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=82=92=E3=82=82=E3=81=A8=E3=81=AB=E3=83=9A=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=82=92=E5=86=8D=E6=A7=8B=E6=88=90=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ts/client/Administrator/HistoryAdministrator.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ts/client/Administrator/HistoryAdministrator.ts b/src/ts/client/Administrator/HistoryAdministrator.ts index 9dd0196..14f3843 100644 --- a/src/ts/client/Administrator/HistoryAdministrator.ts +++ b/src/ts/client/Administrator/HistoryAdministrator.ts @@ -10,13 +10,12 @@ export class HistoryAdministrator{ constructor(app:IAppUsedToReadAndChangePage){ this.app = app; this.urlAd = new URLAdministrator(app) - window.addEventListener('popstate', (event) => { - + window.addEventListener('popstate', ({state}) => { + this.app.transition(state.pageState,state.requiredObject,{ifAppendHistory:false}) }); } clearIntroduction(){ localStorage.setItem("KSSRs::HistoryAdministrator::clearIntroduction_v1","true") - } checkIfIntroductionIsOver(){ return localStorage.getItem("KSSRs::HistoryAdministrator::clearIntroduction_v1") === "true" From ca02c9ceedf8ee095c4c8de92575ea8ba84aa4ae Mon Sep 17 00:00:00 2001 From: Appbird Date: Thu, 2 Sep 2021 23:30:20 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E3=82=82=E3=81=A8=E3=82=82=E3=81=A8?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=9F?= =?UTF-8?q?appendHistory=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=AE?= =?UTF-8?q?=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=97=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ts/client/App.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ts/client/App.ts b/src/ts/client/App.ts index d05d336..e3019a6 100644 --- a/src/ts/client/App.ts +++ b/src/ts/client/App.ts @@ -109,8 +109,6 @@ export default class App implements IAppUsedToChangeState{ } async transition(nextState:T, requestObject:RequiredObjectType,{ifAppendHistory=true,title=""}:{ifAppendHistory?:boolean,title?:string} = {}){ this.goToTop(); - if (ifAppendHistory) this.historyAd.appendHistory() - try { await this.transitionAd.transition(nextState,requestObject,{title:title}) if (ifAppendHistory) this.historyAd.registerCurrentPage();