Skip to content

Commit

Permalink
Update key
Browse files Browse the repository at this point in the history
  • Loading branch information
NPJigaK committed Oct 20, 2023
1 parent 6e29f1c commit bcd70a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions components/AppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import RefreshListsButton from "./RefreshListsButton";
import CheckDoneButton from "./CheckDoneButton";
import { useNowAllFollowers } from "@/lib/accessTwitch";
import { debugLogger } from "@/lib/debugLogger";
import { lastCheckedDateKey } from "@/lib/constants";

export default function AppContainer() {
debugLogger("AppContainer");
const [activeTab, setActiveTab] = useState("Follower List");
const [lastCheckedDate, setLastCheckedDate] = useState<string | null>(
localStorage.getItem("ftls")
localStorage.getItem(lastCheckedDateKey)
);

const {
Expand Down Expand Up @@ -98,13 +99,13 @@ export default function AppContainer() {
debugLogger("onChecked");
storeNowFollowes();
const ftls = formatToLocaleString(new Date());
localStorage.setItem("ftls", ftls);
localStorage.setItem(lastCheckedDateKey, ftls);
setLastCheckedDate(ftls);
}, [storeNowFollowes]);

useEffect(() => {
debugLogger("onChecked();");
if (!localStorage.getItem("ftls")) {
if (!localStorage.getItem(lastCheckedDateKey)) {
onChecked();
}
}, [onChecked]);
Expand Down
4 changes: 2 additions & 2 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export const clientId = "h0pe6dkb6r51jzkk27ujasldoqgio9";
export const redirectUri = "http://localhost:3000/";
export const scope = "moderator:read:followers";
export const accessTokenKey = "twitchAccessToken";
export const lastCheckedDateKey = "lastCheckedDateKey";
export const storedAllFollowersKey = "storedAllFollowersKey";
export const lastCheckedDateKey = "lastCheckedDate";
export const storedAllFollowersKey = "previousFollowersKey";
10 changes: 5 additions & 5 deletions lib/debugLogger.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const isDebugMode = (): boolean => {
return true;
// if (typeof window !== "undefined") {
// return window.location.hash.includes("debug");
// }
// return false;
if (typeof window !== "undefined") {
// Make it server-side compatible.
return window.location.hash.includes("debug");
}
return false;
};
export const debugLogger = (...messages: any[]): void => {
if (isDebugMode()) {
Expand Down

0 comments on commit bcd70a2

Please sign in to comment.