本文整理汇总了TypeScript中flash-store.FlashStoreSync.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FlashStoreSync.get方法的具体用法?TypeScript FlashStoreSync.get怎么用?TypeScript FlashStoreSync.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flash-store.FlashStoreSync
的用法示例。
在下文中一共展示了FlashStoreSync.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getRoomMemberIdList
public async getRoomMemberIdList(
roomId: string,
dirty = false,
): Promise<string[]> {
log.verbose('PuppetPadchatManager', 'getRoomMemberIdList(%d)', roomId)
if (!this.cacheRoomMemberRawPayload) {
throw new Error('cache not inited' )
}
if (dirty) {
this.roomMemberRawPayloadDirty(roomId)
}
const memberRawPayloadDict = this.cacheRoomMemberRawPayload.get(roomId)
|| await this.syncRoomMember(roomId)
if (!memberRawPayloadDict) {
// or return [] ?
throw new Error('roomId not found: ' + roomId)
}
const memberIdList = Object.keys(memberRawPayloadDict)
// console.log('memberRawPayloadDict:', memberRawPayloadDict)
log.verbose('PuppetPadchatManager', 'getRoomMemberIdList(%d) length=%d', roomId, memberIdList.length)
return memberIdList
}
示例2: roomMemberRawPayload
public async roomMemberRawPayload(roomId: string): Promise<{ [contactId: string]: PadchatRoomMemberPayload }> {
log.verbose('PuppetPadchatManager', 'roomMemberRawPayload(%s)', roomId)
if (!this.cacheRoomMemberRawPayload) {
throw new Error('cache not inited' )
}
const memberRawPayloadDict = this.cacheRoomMemberRawPayload.get(roomId)
|| await this.syncRoomMember(roomId)
if (!memberRawPayloadDict) {
throw new Error('roomId not found: ' + roomId)
}
return memberRawPayloadDict
}
示例3: syncRoomMember
public async syncRoomMember(
roomId: string,
): Promise<{ [contactId: string]: PadchatRoomMemberPayload }> {
log.silly('PuppetPadchatManager', 'syncRoomMember(%s)', roomId)
const memberListPayload = await this.WXGetChatRoomMember(roomId)
if (!memberListPayload || !('user_name' in memberListPayload)) { // check user_name too becasue the server might return {}
/**
* Room Id not exist
* See: https://github.com/lijiarui/wechaty-puppet-padchat/issues/64#issuecomment-397319016
*/
this.roomMemberRawPayloadDirty(roomId)
this.roomRawPayloadDirty(roomId)
return {}
}
log.silly('PuppetPadchatManager', 'syncRoomMember(%s) total %d members',
roomId,
Object.keys(memberListPayload).length,
)
const memberDict: { [contactId: string]: PadchatRoomMemberPayload } = {}
for (const memberPayload of memberListPayload.member) {
const contactId = memberPayload.user_name
memberDict[contactId] = memberPayload
}
if (!this.cacheRoomMemberRawPayload) {
throw new Error('cache not inited' )
}
const oldMemberDict = this.cacheRoomMemberRawPayload.get(roomId)
const newMemberDict = {
...oldMemberDict,
...memberDict,
}
this.cacheRoomMemberRawPayload.set(roomId, newMemberDict)
return newMemberDict
}
示例4: retry
const rawPayload = await Misc.retry(async (retry, attempt) => {
log.silly('PuppetPadchatManager', 'roomRawPayload(%s) retry() attempt=%d', id, attempt)
if (!this.cacheRoomRawPayload) {
throw new Error('no cache')
}
if (this.cacheRoomRawPayload.has(id)) {
return this.cacheRoomRawPayload.get(id)
}
const tryRawPayload = await this.WXGetRoomPayload(id)
// check user_name too becasue the server might return {}
// See issue #1358 https://github.com/Chatie/wechaty/issues/1358
if (tryRawPayload /* && tryRawPayload.user_name */) {
this.cacheRoomRawPayload.set(id, tryRawPayload)
return tryRawPayload
}
return retry(new Error('tryRawPayload empty'))
})