|
@ -105,13 +105,10 @@ |
|
|
showGivenToUser="true" |
|
|
showGivenToUser="true" |
|
|
/> |
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Results List --> |
|
|
<div class="bg-slate-100 rounded-md overflow-hidden px-4 py-3 mb-4"> |
|
|
<div class="bg-slate-100 rounded-md overflow-hidden px-4 py-3 mb-4"> |
|
|
<h2 class="text-xl font-bold mb-4">Latest Activity</h2> |
|
|
<h2 class="text-xl font-bold mb-4">Latest Activity</h2> |
|
|
<div :class="{ hidden: isHiddenSpinner }"> |
|
|
<InfiniteScroll @reached-bottom="loadMoreGives"> |
|
|
<p class="text-slate-500 text-center italic mt-4 mb-4"> |
|
|
|
|
|
<fa icon="spinner" class="fa-spin-pulse"></fa> Loading… |
|
|
|
|
|
</p> |
|
|
|
|
|
</div> |
|
|
|
|
|
<ul class="border-t border-slate-300"> |
|
|
<ul class="border-t border-slate-300"> |
|
|
<li |
|
|
<li |
|
|
class="border-b border-slate-300 py-2" |
|
|
class="border-b border-slate-300 py-2" |
|
@ -120,10 +117,11 @@ |
|
|
> |
|
|
> |
|
|
<div |
|
|
<div |
|
|
class="border-b border-dashed border-slate-400 text-orange-400 pb-2 mb-2 font-bold uppercase text-sm" |
|
|
class="border-b border-dashed border-slate-400 text-orange-400 pb-2 mb-2 font-bold uppercase text-sm" |
|
|
v-if="record.jwtId == feedLastViewedId" |
|
|
v-if="record.jwtId == feedLastViewedClaimId" |
|
|
> |
|
|
> |
|
|
You've seen all the following |
|
|
You've seen all the following |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="flex"> |
|
|
<div class="flex"> |
|
|
<fa icon="gift" class="pt-1 pr-2 text-slate-500"></fa> |
|
|
<fa icon="gift" class="pt-1 pr-2 text-slate-500"></fa> |
|
|
<span class="">{{ this.giveDescription(record) }}</span> |
|
|
<span class="">{{ this.giveDescription(record) }}</span> |
|
@ -133,14 +131,27 @@ |
|
|
</div> |
|
|
</div> |
|
|
</li> |
|
|
</li> |
|
|
</ul> |
|
|
</ul> |
|
|
|
|
|
</InfiniteScroll> |
|
|
|
|
|
<div :class="{ hidden: isHiddenSpinner }"> |
|
|
|
|
|
<p class="text-slate-500 text-center italic mt-4 mb-4"> |
|
|
|
|
|
<fa icon="spinner" class="fa-spin-pulse"></fa> Loading… |
|
|
|
|
|
</p> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</section> |
|
|
</section> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
|
|
|
|
|
|
|
|
|
import EntityIcon from "@/components/EntityIcon.vue"; |
|
|
import GiftedDialog from "@/components/GiftedDialog.vue"; |
|
|
import GiftedDialog from "@/components/GiftedDialog.vue"; |
|
|
|
|
|
import InfiniteScroll from "@/components/InfiniteScroll.vue"; |
|
|
|
|
|
import QuickNav from "@/components/QuickNav.vue"; |
|
|
|
|
|
import TopMessage from "@/components/TopMessage"; |
|
|
import { db, accountsDB } from "@/db/index"; |
|
|
import { db, accountsDB } from "@/db/index"; |
|
|
|
|
|
import { Account } from "@/db/tables/accounts"; |
|
|
|
|
|
import { Contact } from "@/db/tables/contacts"; |
|
|
import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; |
|
|
import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; |
|
|
import { accessToken } from "@/libs/crypto"; |
|
|
import { accessToken } from "@/libs/crypto"; |
|
|
import { |
|
|
import { |
|
@ -148,12 +159,7 @@ import { |
|
|
GiverInputInfo, |
|
|
GiverInputInfo, |
|
|
GiveServerRecord, |
|
|
GiveServerRecord, |
|
|
} from "@/libs/endorserServer"; |
|
|
} from "@/libs/endorserServer"; |
|
|
import { Contact } from "@/db/tables/contacts"; |
|
|
|
|
|
import QuickNav from "@/components/QuickNav.vue"; |
|
|
|
|
|
import EntityIcon from "@/components/EntityIcon.vue"; |
|
|
|
|
|
import TopMessage from "@/components/TopMessage"; |
|
|
|
|
|
import { IIdentifier } from "@veramo/core"; |
|
|
import { IIdentifier } from "@veramo/core"; |
|
|
import { Account } from "@/db/tables/accounts"; |
|
|
|
|
|
|
|
|
|
|
|
interface Notification { |
|
|
interface Notification { |
|
|
group: string; |
|
|
group: string; |
|
@ -163,7 +169,7 @@ interface Notification { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
components: { GiftedDialog, QuickNav, EntityIcon, TopMessage }, |
|
|
components: { GiftedDialog, QuickNav, EntityIcon, InfiniteScroll, TopMessage }, |
|
|
}) |
|
|
}) |
|
|
export default class HomeView extends Vue { |
|
|
export default class HomeView extends Vue { |
|
|
$notify!: (notification: Notification, timeout?: number) => void; |
|
|
$notify!: (notification: Notification, timeout?: number) => void; |
|
@ -172,10 +178,9 @@ export default class HomeView extends Vue { |
|
|
allContacts: Array<Contact> = []; |
|
|
allContacts: Array<Contact> = []; |
|
|
allMyDids: Array<string> = []; |
|
|
allMyDids: Array<string> = []; |
|
|
apiServer = ""; |
|
|
apiServer = ""; |
|
|
feedAllLoaded = false; |
|
|
|
|
|
feedData = []; |
|
|
feedData = []; |
|
|
feedPreviousOldestId?: string; |
|
|
feedPreviousOldestId?: string; |
|
|
feedLastViewedId?: string; |
|
|
feedLastViewedClaimId?: string; |
|
|
isHiddenSpinner = true; |
|
|
isHiddenSpinner = true; |
|
|
isRegistered = false; |
|
|
isRegistered = false; |
|
|
numAccounts = 0; |
|
|
numAccounts = 0; |
|
@ -215,9 +220,12 @@ export default class HomeView extends Vue { |
|
|
this.apiServer = settings?.apiServer || ""; |
|
|
this.apiServer = settings?.apiServer || ""; |
|
|
this.activeDid = settings?.activeDid || ""; |
|
|
this.activeDid = settings?.activeDid || ""; |
|
|
this.allContacts = await db.contacts.toArray(); |
|
|
this.allContacts = await db.contacts.toArray(); |
|
|
this.feedLastViewedId = settings?.lastViewedClaimId; |
|
|
this.feedLastViewedClaimId = settings?.lastViewedClaimId; |
|
|
this.isRegistered = !!settings?.isRegistered; |
|
|
this.isRegistered = !!settings?.isRegistered; |
|
|
|
|
|
|
|
|
|
|
|
// this returns a Promise but we don't need to wait for it |
|
|
this.updateAllFeed(); |
|
|
this.updateAllFeed(); |
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
|
} catch (err: any) { |
|
|
} catch (err: any) { |
|
|
this.$notify( |
|
|
this.$notify( |
|
@ -260,24 +268,33 @@ export default class HomeView extends Vue { |
|
|
return headers; |
|
|
return headers; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Data loader used by infinite scroller |
|
|
|
|
|
* @param payload is the flag from the InfiniteScroll indicating if it should load |
|
|
|
|
|
**/ |
|
|
|
|
|
public async loadMoreGives(payload: boolean) { |
|
|
|
|
|
if (payload) { |
|
|
|
|
|
this.updateAllFeed(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public async updateAllFeed() { |
|
|
public async updateAllFeed() { |
|
|
this.isHiddenSpinner = false; |
|
|
this.isHiddenSpinner = false; |
|
|
await this.retrieveClaims(this.apiServer, this.feedPreviousOldestId) |
|
|
await this.retrieveGives(this.apiServer, this.feedPreviousOldestId) |
|
|
.then(async (results) => { |
|
|
.then(async (results) => { |
|
|
if (results.data.length > 0) { |
|
|
if (results.data.length > 0) { |
|
|
this.feedData = this.feedData.concat(results.data); |
|
|
this.feedData = this.feedData.concat(results.data); |
|
|
this.feedAllLoaded = results.hitLimit; |
|
|
|
|
|
this.feedPreviousOldestId = |
|
|
this.feedPreviousOldestId = |
|
|
results.data[results.data.length - 1].jwtId; |
|
|
results.data[results.data.length - 1].jwtId; |
|
|
|
|
|
// The following update is only done on the first load. |
|
|
if ( |
|
|
if ( |
|
|
this.feedLastViewedId == null || |
|
|
this.feedLastViewedClaimId == null || |
|
|
this.feedLastViewedId < results.data[0].jwtId |
|
|
this.feedLastViewedClaimId < results.data[0].jwtId |
|
|
) { |
|
|
) { |
|
|
await db.open(); |
|
|
await db.open(); |
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
lastViewedClaimId: results.data[0].jwtId, |
|
|
lastViewedClaimId: results.data[0].jwtId, |
|
|
}); |
|
|
}); |
|
|
// but not for this page because we need to remember what it was before |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
@ -287,17 +304,22 @@ export default class HomeView extends Vue { |
|
|
{ |
|
|
{ |
|
|
group: "alert", |
|
|
group: "alert", |
|
|
type: "danger", |
|
|
type: "danger", |
|
|
title: "Export Error", |
|
|
title: "Feed Error", |
|
|
text: e.userMessage || "There was an error retrieving feed data.", |
|
|
text: e.userMessage || "There was an error retrieving feed data.", |
|
|
}, |
|
|
}, |
|
|
-1, |
|
|
-1, |
|
|
); |
|
|
); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.isHiddenSpinner = true; |
|
|
this.isHiddenSpinner = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async retrieveClaims(endorserApiServer: string, beforeId?: string) { |
|
|
/** |
|
|
|
|
|
* Retrieve claims in reverse chronological order |
|
|
|
|
|
* |
|
|
|
|
|
* @param beforeId the earliest ID (of previous searches) to search earlier |
|
|
|
|
|
* @return claims in reverse chronological order |
|
|
|
|
|
*/ |
|
|
|
|
|
public async retrieveGives(endorserApiServer: string, beforeId?: string) { |
|
|
const beforeQuery = beforeId == null ? "" : "&beforeId=" + beforeId; |
|
|
const beforeQuery = beforeId == null ? "" : "&beforeId=" + beforeId; |
|
|
const response = await fetch( |
|
|
const response = await fetch( |
|
|
endorserApiServer + "/api/v2/report/gives?" + beforeQuery, |
|
|
endorserApiServer + "/api/v2/report/gives?" + beforeQuery, |
|
|