Skip to content

Commit

Permalink
Merge pull request #3072 from tahowallet/completed-abilities
Browse files Browse the repository at this point in the history
Fetch completed abilities
  • Loading branch information
jagodarybacka authored Mar 10, 2023
2 parents f240a82 + adebed0 commit 87db50f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions background/lib/daylight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type DaylightAbility = {
openAt: string | null
closeAt: string | null
isClosed: boolean | null
walletCompleted: boolean | null
createdAt: string
chain: string
sourceId: string
Expand Down Expand Up @@ -95,6 +96,8 @@ export const getDaylightAbilities = async (
// The limit needs to be set. It is set to the highest value.
requestURL.searchParams.set("limit", "1000")
requestURL.searchParams.set("deadline", "all")
requestURL.searchParams.set("showCompleted", "true")
requestURL.searchParams.set("markAsShown", "true")

try {
const response: AbilitiesResponse = await fetchJson({
Expand Down
1 change: 0 additions & 1 deletion background/redux-slices/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const abilitiesSlice = createSlice({
immerState.abilities[address][ability.abilityId]
immerState.abilities[address][ability.abilityId] = {
...ability,
completed: existingAbility.completed,
removedFromUi: existingAbility.removedFromUi,
}
} else {
Expand Down
5 changes: 4 additions & 1 deletion background/services/abilities/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ export class AbilitiesDatabase extends Dexie {
id: number
}
if (JSON.stringify(correctAbility) !== JSON.stringify(ability)) {
const updateCompleted =
ability.completed === true && existingAbility.completed === false

await this.abilities.update(existingAbility, {
...ability,
completed: existingAbility.completed,
completed: updateCompleted ? true : existingAbility.completed,
removedFromUi: existingAbility.removedFromUi,
})
return true
Expand Down
2 changes: 1 addition & 1 deletion background/services/abilities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const normalizeDaylightAbilities = (
imageUrl: daylightAbility.imageUrl || undefined,
openAt: daylightAbility.openAt || undefined,
closeAt: daylightAbility.closeAt || undefined,
completed: false,
completed: daylightAbility.walletCompleted || false,
removedFromUi: false,
address: normalizeEVMAddress(address),
requirement: normalizeDaylightRequirements(
Expand Down

0 comments on commit 87db50f

Please sign in to comment.