From cd9177cc1bb41485061adaf192288cd5cd26d163 Mon Sep 17 00:00:00 2001 From: HF Date: Fri, 19 Aug 2022 15:34:56 +0200 Subject: [PATCH] change how coords are storedin modtools fix persist/REHYDRATE --- src/components/Captcha.jsx | 2 -- src/components/ModCanvastools.jsx | 53 ++++++++++--------------------- src/components/ModWatchtools.jsx | 32 +++++++------------ src/components/Modtools.jsx | 2 +- src/components/Tab.jsx | 2 +- src/core/popUps.js | 2 -- src/store/reducers/windows.js | 8 +++-- src/store/sharedReducers.js | 5 +-- src/store/store.js | 2 ++ src/styles/default.css | 17 ++++++---- 10 files changed, 53 insertions(+), 72 deletions(-) diff --git a/src/components/Captcha.jsx b/src/components/Captcha.jsx index 460044f..024aa3a 100644 --- a/src/components/Captcha.jsx +++ b/src/components/Captcha.jsx @@ -71,7 +71,6 @@ const Captcha = ({ autoload, width }) => { ({t`Tip: Not case-sensitive; I and l are the same`})

-
{errors.map((error) => (

{t`Error`}: {error} @@ -149,7 +148,6 @@ const Captcha = ({ autoload, width }) => { }} /> -
); }; diff --git a/src/components/ModCanvastools.jsx b/src/components/ModCanvastools.jsx index 1e59e15..09a31ca 100644 --- a/src/components/ModCanvastools.jsx +++ b/src/components/ModCanvastools.jsx @@ -145,13 +145,6 @@ function ModCanvastools() { const [cleanAction, selectCleanAction] = useState('spare'); const [protAction, selectProtAction] = useState('protect'); const [date, selectDate] = useState(maxDate); - const [coords, selectCoords] = useState(keptState.coords); - const [tlcoords, selectTLCoords] = useState(keptState.tlcoords); - const [brcoords, selectBRCoords] = useState(keptState.brcoords); - const [tlrcoords, selectTLRCoords] = useState(keptState.tlrcoords); - const [brrcoords, selectBRRCoords] = useState(keptState.brrcoords); - const [tlccoords, selectTLCCoords] = useState(keptState.tlccoords); - const [brccoords, selectBRCCoords] = useState(keptState.brccoords); const [resp, setResp] = useState(null); const [cleanerstats, setCleanerStats] = useState({}); const [submitting, setSubmitting] = useState(false); @@ -201,10 +194,6 @@ function ModCanvastools() { // nothing } - useEffect(() => { - getCleanerStats((stats) => setCleanerStats(stats)); - }, []); - useInterval(() => { getCleanerStats((stats) => setCleanerStats(stats)); }, 10000); @@ -278,7 +267,7 @@ function ModCanvastools() {

{t`Coordinates in X_Y format:`}  { - const co = evt.target.value.trim(); - selectCoords(co); - keptState.coords = co; + keptState.coords = evt.target.value.trim(); }} />

@@ -303,7 +290,7 @@ function ModCanvastools() { submitImageAction( imageAction, selectedCanvas, - coords, + keptState.coords, (ret) => { setSubmitting(false); setResp(ret); @@ -341,7 +328,7 @@ function ModCanvastools() {

{t`Top-left corner`} (X_Y):  { const co = evt.target.value.trim(); - selectTLCoords(co); keptState.tlcoords = co; }} /> @@ -359,7 +345,7 @@ function ModCanvastools() {

{t`Bottom-right corner`} (X_Y):  { const co = evt.target.value.trim(); - selectBRCoords(co); keptState.brcoords = co; }} /> @@ -384,8 +369,8 @@ function ModCanvastools() { submitProtAction( protAction, selectedCanvas, - tlcoords, - brcoords, + keptState.tlcoords, + keptState.brcoords, (ret) => { setSubmitting(false); setResp(ret); @@ -416,7 +401,7 @@ function ModCanvastools() {

{t`Top-left corner`} (X_Y):  { const co = evt.target.value.trim(); - selectTLRCoords(co); keptState.tlrcoords = co; }} /> @@ -434,7 +418,7 @@ function ModCanvastools() {

{t`Bottom-right corner`} (X_Y):  { const co = evt.target.value.trim(); - selectBRRCoords(co); keptState.brrcoords = co; }} /> @@ -459,8 +442,8 @@ function ModCanvastools() { submitRollback( date, selectedCanvas, - tlrcoords, - brrcoords, + keptState.tlrcoords, + keptState.brrcoords, (ret) => { setSubmitting(false); setResp(ret); @@ -501,7 +484,7 @@ function ModCanvastools() {

{t`Top-left corner`} (X_Y):  { const co = evt.target.value.trim(); - selectTLCCoords(co); keptState.tlccoords = co; }} /> @@ -519,7 +501,7 @@ function ModCanvastools() {

{t`Bottom-right corner`} (X_Y):  { const co = evt.target.value.trim(); - selectBRCCoords(co); keptState.brccoords = co; }} /> @@ -544,15 +525,15 @@ function ModCanvastools() { submitCanvasCleaner( cleanAction, selectedCanvas, - tlccoords, - brccoords, + keptState.tlccoords, + keptState.brccoords, (ret) => { setCleanerStats({ running: true, percent: 'N/A', method: cleanAction, - tl: tlccoords, - br: brccoords, + tl: keptState.tlccoords, + br: keptState.brccoords, canvasId: selectedCanvas, }); setSubmitting(false); diff --git a/src/components/ModWatchtools.jsx b/src/components/ModWatchtools.jsx index a4a6893..7134d98 100644 --- a/src/components/ModWatchtools.jsx +++ b/src/components/ModWatchtools.jsx @@ -70,13 +70,9 @@ async function submitWatchAction( function ModWatchtools() { const [selectedCanvas, selectCanvas] = useState(0); - const [tlcoords, selectTLCoords] = useState(keepState.tlcoords); - const [brcoords, selectBRCoords] = useState(keepState.brcoords); - const [interval, selectInterval] = useState(keepState.interval); const [sortAsc, setSortAsc] = useState(true); const [sortBy, setSortBy] = useState(0); const [table, setTable] = useState({}); - const [iid, selectIid] = useState(keepState.iid); const [resp, setResp] = useState(null); const [submitting, setSubmitting] = useState(false); @@ -137,7 +133,7 @@ function ModWatchtools() { {` ${t`Interval`}: `} { const newInterval = evt.target.value.trim(); - selectInterval(newInterval); keepState.interval = newInterval; }} /> {` ${t`IID (optional)`}: `} { const newIid = evt.target.value.trim(); - selectIid(newIid); keepState.iid = newIid; }} /> @@ -171,7 +165,7 @@ function ModWatchtools() {

{t`Top-left corner`} (X_Y):  { const co = evt.target.value.trim(); - selectTLCoords(co); keepState.tlcoords = co; }} /> @@ -189,7 +182,7 @@ function ModWatchtools() {

{t`Bottom-right corner`} (X_Y):  { const co = evt.target.value.trim(); - selectBRCoords(co); keepState.brcoords = co; }} /> @@ -214,10 +206,10 @@ function ModWatchtools() { submitWatchAction( 'all', selectedCanvas, - tlcoords, - brcoords, - interval, - iid, + keepState.tlcoords, + keepState.brcoords, + keepState.interval, + keepState.iid, (ret) => { setSubmitting(false); setResp(ret.info); @@ -245,10 +237,10 @@ function ModWatchtools() { submitWatchAction( 'summary', selectedCanvas, - tlcoords, - brcoords, - interval, - iid, + keepState.tlcoords, + keepState.brcoords, + keepState.interval, + keepState.iid, (ret) => { setSubmitting(false); setResp(ret.info); diff --git a/src/components/Modtools.jsx b/src/components/Modtools.jsx index 6d0c688..ebf28de 100644 --- a/src/components/Modtools.jsx +++ b/src/components/Modtools.jsx @@ -30,7 +30,7 @@ function Modtools() { return ( <> -

+
{parts.map((part, ind) => ( { let className = 'tab-list-item'; if (active) { - className += ' tab-list-active'; + className += ' active'; } return ( diff --git a/src/core/popUps.js b/src/core/popUps.js index 22e59af..b4b8431 100644 --- a/src/core/popUps.js +++ b/src/core/popUps.js @@ -64,6 +64,4 @@ class PopUps { const popUps = new PopUps(); -window.lol = popUps.wins; - export default popUps; diff --git a/src/store/reducers/windows.js b/src/store/reducers/windows.js index 3ad2e4a..9879a30 100644 --- a/src/store/reducers/windows.js +++ b/src/store/reducers/windows.js @@ -183,6 +183,9 @@ export default function windows( state = initialState, action, ) { + if (action.type.startsWith('persist')) { + console.log(action); + } switch (action.type) { case 'OPEN_WIN': { /* @@ -496,14 +499,15 @@ export default function windows( case 'persist/REHYDRATE': { const { showWindows } = state; - if (!showWindows) { + if (!showWindows || action.key !== 'wind') { // don't persist on small screens return state; } + console.log(action); const loadedState = { ...state, - ...action.payload.windows, + ...action.payload, }; const args = { ...loadedState.args }; const positions = { ...loadedState.positions }; diff --git a/src/store/sharedReducers.js b/src/store/sharedReducers.js index 1ae88b5..f30bdb8 100644 --- a/src/store/sharedReducers.js +++ b/src/store/sharedReducers.js @@ -11,10 +11,11 @@ import gui from './reducers/gui'; import ranks from './reducers/ranks'; import chatRead from './reducers/chatRead'; -export const CURRENT_VERSION = 8; +export const CURRENT_VERSION = 11; export const migrate = (state, version) => { - if (!state || version !== CURRENT_VERSION) { + console.log('migrate', state, version); + if (!state || !state._persist || state._persist.version !== version) { console.log('Newer version run, resetting store.'); return Promise.resolve({}); } diff --git a/src/store/store.js b/src/store/store.js index 23ebb25..02475fa 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -73,4 +73,6 @@ const store = createStore( persistStore(store); +window.lol = store; + export default store; diff --git a/src/styles/default.css b/src/styles/default.css index e78a567..e1b4648 100644 --- a/src/styles/default.css +++ b/src/styles/default.css @@ -144,14 +144,14 @@ a:hover { padding: 0.5rem 0.75rem; } -.tab-list-item:hover { - background-color: #6d6d6d; - border: solid #ccc; - border-width: 1px 1px 0 1px; +.tab-list-item:not(.active):hover { + background-color: #dbdbdb; + cursor: pointer; } -.tab-list-active { +.tab-list-item.active { background-color: white; + color: #262a30; border: solid #ccc; border-width: 1px 1px 0 1px; } @@ -555,6 +555,11 @@ tr:nth-child(even) { font-size: 16px; } +.Alert p,.window p { + margin-top: 12px; + margin-bottom: 12px; +} + .content { padding-left: 5%; padding-right: 5%; @@ -742,7 +747,7 @@ table td span, .chatname, .mention, .ping { vertical-align: bottom; } table td span { - max-width: 140px; + max-width: 180px; } .chatname { padding-left: 4px;