mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(p/all): auto time filter didn't show posts from last visit
This commit is contained in:
@@ -51,10 +51,43 @@ const useTimeFilter = () => {
|
||||
timeFilterName = lastVisitTimeFilterName;
|
||||
}
|
||||
|
||||
assert(!timeFilterName || typeof timeFilterName === 'string', `useTimeFilter timeFilterName argument '${timeFilterName}' not a string`);
|
||||
const timeFilterSeconds = timeFilterNamesToSeconds[timeFilterName as keyof typeof timeFilterNamesToSeconds];
|
||||
assert(!timeFilterName || timeFilterName === 'all' || timeFilterSeconds !== undefined, `useTimeFilter no filter for timeFilterName '${timeFilterName}'`);
|
||||
return { timeFilterSeconds, timeFilterNames, timeFilterName };
|
||||
let timeFilterSeconds: number | undefined;
|
||||
|
||||
if (timeFilterName === 'all') {
|
||||
timeFilterSeconds = undefined;
|
||||
} else if (timeFilterName && timeFilterName in timeFilterNamesToSeconds) {
|
||||
timeFilterSeconds = timeFilterNamesToSeconds[timeFilterName as keyof typeof timeFilterNamesToSeconds];
|
||||
} else if (timeFilterName) {
|
||||
// Handle dynamic time filters (e.g., "3d", "2w")
|
||||
const match = timeFilterName.match(/^(\d+)([dwmy])$/);
|
||||
if (match) {
|
||||
const [, value, unit] = match;
|
||||
const numValue = parseInt(value, 10);
|
||||
switch (unit) {
|
||||
case 'd':
|
||||
timeFilterSeconds = numValue * 24 * 60 * 60;
|
||||
break;
|
||||
case 'w':
|
||||
timeFilterSeconds = numValue * 7 * 24 * 60 * 60;
|
||||
break;
|
||||
case 'm':
|
||||
timeFilterSeconds = numValue * 30 * 24 * 60 * 60;
|
||||
break;
|
||||
case 'y':
|
||||
timeFilterSeconds = numValue * 365 * 24 * 60 * 60;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we still don't have a valid timeFilterSeconds, use the default (24h)
|
||||
if (timeFilterSeconds === undefined && timeFilterName !== 'all') {
|
||||
timeFilterSeconds = timeFilterNamesToSeconds['24h'];
|
||||
}
|
||||
|
||||
assert(timeFilterName === 'all' || timeFilterSeconds !== undefined, `useTimeFilter no filter for timeFilterName '${timeFilterName}'`);
|
||||
|
||||
return { timeFilterSeconds, timeFilterNames, timeFilterName, lastVisitTimeFilterName };
|
||||
};
|
||||
|
||||
export default useTimeFilter;
|
||||
|
||||
@@ -4,8 +4,7 @@ import extName from 'ext-name';
|
||||
import { canEmbed } from '../../components/embed';
|
||||
import memoize from 'memoizee';
|
||||
import { isValidURL } from './url-utils';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { CapacitorHttp } from '@capacitor/core';
|
||||
import { Capacitor, CapacitorHttp } from '@capacitor/core';
|
||||
|
||||
export interface CommentMediaInfo {
|
||||
url: string;
|
||||
|
||||
Reference in New Issue
Block a user