mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor: allow to return undefined in getZapSplits function
This commit is contained in:
parent
3bc3e7675d
commit
beee0e76e7
1 changed files with 3 additions and 3 deletions
|
|
@ -6,12 +6,12 @@ type ExtraMessage = string;
|
||||||
/** Number from 1 to 100, stringified. */
|
/** Number from 1 to 100, stringified. */
|
||||||
type splitPercentages = string;
|
type splitPercentages = string;
|
||||||
|
|
||||||
type DittoZapSplits = {
|
export type DittoZapSplits = {
|
||||||
[key: Pubkey]: [splitPercentages, ExtraMessage];
|
[key: Pubkey]: [splitPercentages, ExtraMessage];
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Gets zap splits from NIP-78 in DittoZapSplits format. */
|
/** Gets zap splits from NIP-78 in DittoZapSplits format. */
|
||||||
export async function getZapSplits(store: NStore, pubkey: string): Promise<DittoZapSplits> {
|
export async function getZapSplits(store: NStore, pubkey: string): Promise<DittoZapSplits | undefined> {
|
||||||
const zapSplits: DittoZapSplits = {};
|
const zapSplits: DittoZapSplits = {};
|
||||||
|
|
||||||
const [event] = await store.query([{
|
const [event] = await store.query([{
|
||||||
|
|
@ -20,7 +20,7 @@ export async function getZapSplits(store: NStore, pubkey: string): Promise<Ditto
|
||||||
'#d': ['pub.ditto.zapSplits'],
|
'#d': ['pub.ditto.zapSplits'],
|
||||||
limit: 1,
|
limit: 1,
|
||||||
}]);
|
}]);
|
||||||
if (!event) return {};
|
if (!event) return;
|
||||||
|
|
||||||
for (const tag of event.tags) {
|
for (const tag of event.tags) {
|
||||||
if (
|
if (
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue