Skip to content

Commit

Permalink
improve logic forward
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhdanh27600 committed Oct 23, 2023
1 parent 768dbec commit d021361
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/screens/URLTracking/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const URLTracking = ({ hash }: { hash: string }) => {
<div className="mt-8">
<ShortenUrlTile />
<URLShare />
<URLAdvancedSetting defaultOpen={false} shortenUrl={shortenUrl} />
<URLAdvancedSetting />
</div>
<div className="m-4">
<FeedbackLink template={FeedbackTemplate.URL_TRACKING} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/sections/NoteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export const NoteInput = () => {
className="mx-auto mt-4 flex w-fit min-w-[5rem] justify-center"
animation
/>
{hasNote && <URLAdvancedSetting defaultOpen={false} />}
{hasNote && <URLAdvancedSetting />}
<FeedbackLink template={FeedbackTemplate.NOTE} />
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/sections/URLAdvancedSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const tabs: Tab[] = [
},
];

export const URLAdvancedSetting = ({ defaultOpen = true }: { defaultOpen?: boolean; shortenUrl?: string }) => {
export const URLAdvancedSetting = () => {
const { t, locale } = useTrans();
const [selectedKey, setSelectedKey] = useState(tabs[0]?.key);

Expand All @@ -51,7 +51,7 @@ export const URLAdvancedSetting = ({ defaultOpen = true }: { defaultOpen?: boole
);

return (
<Accordion title={title} defaultOpen={defaultOpen} className="my-4">
<Accordion title={title} className="my-4">
<div>
<div className="my-4" />
<Tabs tabs={tabs} selectedKey={selectedKey} setSelectedKey={setSelectedKey} />
Expand Down
5 changes: 2 additions & 3 deletions src/services/cache/shorten.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ export class ShortenCache {
return await redis.hexists(hashKey, 'url');
}
async postShortenHash(history: UrlShortenerHistory) {
let rs: string[] = [];
let data: string[] = [];
Object.entries(history).forEach((cur) => {
if (cur[1]) rs.push(cur[0], cur[1].toString());
if (cur[1]) data.push(cur[0], cur[1].toString());
});
const data = [...rs, 'updatedAt', new Date().getTime()];
const hashKey = getRedisKey(REDIS_KEY.MAP_SHORTEN_BY_HASH, history.hash);
await Promise.all([redis.hset(hashKey, data), redis.expire(hashKey, LIMIT_SHORTENED_SECOND)]);
}
Expand Down

0 comments on commit d021361

Please sign in to comment.