Skip to content

Commit

Permalink
Merge branch 'refs/heads/koni/dev/issue-task-share-leaderboard' into …
Browse files Browse the repository at this point in the history
…telegram-dev-02
  • Loading branch information
anhnhu committed Jun 10, 2024
2 parents 786b349 + d010c22 commit 1dffba5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ const _TaskItem = ({ actionReloadPoint, className, task }: Props): React.ReactEl
console.error('shareLeaderboard', e);
}
}

apiSDK.finishTask(taskId, extrinsicHash, networkKey)
.finally(() => {
setTaskLoading(false);
Expand All @@ -143,7 +142,7 @@ const _TaskItem = ({ actionReloadPoint, className, task }: Props): React.ReactEl
const startEnv = shareLeaderboard.start_time;
const endEnv = shareLeaderboard.end_time;

urlRedirect = await apiSDK.getShareTwitterURL(startEnv, endEnv, shareLeaderboard.content, shareLeaderboard.content_no_template, shareLeaderboard.url);
urlRedirect = await apiSDK.getShareTwitterURL(startEnv, endEnv, shareLeaderboard.content, task.gameId ?? 0, shareLeaderboard.url);
}

telegramConnector.openLink(urlRedirect);
Expand Down
15 changes: 10 additions & 5 deletions packages/extension-koni-ui/src/connector/booka/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,21 +337,26 @@ export class BookaSdk {
return `http://x.com/share?text=${content}&url=${linkApp}`;
}

async getShareTwitterURL (startDate: string, endDate: string, content: string, contentNoTemplate: string, url: string) {
async getShareTwitterURL (startDate: string, endDate: string, content: string, gameId: number, url: string) {
const start = formatDateFully(new Date(startDate));
const end = formatDateFully(new Date(endDate));
const leaderBoard = await this.postRequest<LeaderboardPerson[]>(`${GAME_API_HOST}/api/game/leader-board`, { startDate: start, endDate: end, limit: 1 });
const leaderBoard = await this.postRequest<LeaderboardPerson[]>(`${GAME_API_HOST}/api/game/leader-board`,
{
startDate: start,
endDate: end,
gameId: gameId,
limit: 1 });

const personMine = leaderBoard.find((item) => item.mine);
let contentShare = contentNoTemplate;
let contentShare = '';

if (personMine) {
contentShare = populateTemplateString(content, personMine);
contentShare = `text=${populateTemplateString(content, personMine)}%0A&`;
}

const linkShare = `${url}?startApp=${this.account?.info.inviteCode || 'booka'}`;

return `http://x.com/share?text=${contentShare}%0A&url=${linkShare}`;
return `http://x.com/share?${contentShare}url=${linkShare}`;
}

async fetchReferalList () {
Expand Down
1 change: 0 additions & 1 deletion packages/extension-koni-ui/src/connector/booka/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export enum TaskHistoryStatus {

export interface ShareLeaderboard {
content: string;
content_no_template: string;
url: string;
start_time: string;
end_time: string;
Expand Down

0 comments on commit 1dffba5

Please sign in to comment.