Channels Disappear Fix (#2060)

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-06-11 00:36:47 +06:00 committed by GitHub
parent 211e99017e
commit 0e56a2acc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 13 deletions

View File

@ -15,8 +15,8 @@
label={chunter.string.ArchiveChannel}
justify={'left'}
size={'x-large'}
on:click={() => {
ArchiveChannel(channel, () => dispatch('close'))
on:click={(evt) => {
ArchiveChannel(channel, evt, () => dispatch('close'))
}}
/>
{/if}

View File

@ -105,7 +105,7 @@ export async function UnpinMessage (message: ChunterMessage): Promise<void> {
)
}
export async function ArchiveChannel (channel: Channel, afterArchive?: () => void): Promise<void> {
export async function ArchiveChannel (channel: Channel, evt: any, afterArchive?: () => void): Promise<void> {
showPopup(
MessageBox,
{

View File

@ -69,9 +69,15 @@
)
})
let requestIndex = 0
async function update (model: NavigatorModel, spaces: Space[], preferences: Map<Ref<Doc>, SpacePreference>) {
shownSpaces = spaces.filter(
(sp) => !sp.archived && !preferences.has(sp._id) && (!sp.private || sp.members.includes(myAccId))
)
starred = spaces.filter((sp) => preferences.has(sp._id))
if (model.specials !== undefined) {
const sp = await updateSpecials(model.specials, spaces)
const [sp, resIndex] = await updateSpecials(model.specials, spaces, ++requestIndex)
if (resIndex !== requestIndex) return
const topSpecials = sp.get('top') ?? []
const bottomSpecials = sp.get('bottom') ?? []
sp.delete('top')
@ -88,17 +94,17 @@
} else {
specials = []
}
shownSpaces = spaces.filter(
(sp) => !sp.archived && !preferences.has(sp._id) && (!sp.members.length || sp.members.includes(myAccId))
)
starred = spaces.filter((sp) => preferences.has(sp._id))
}
$: if (model) update(model, spaces, preferences)
async function updateSpecials (specials: SpecialNavModel[], spaces: Space[]): Promise<Map<string, SpecialNavModel[]>> {
async function updateSpecials (
specials: SpecialNavModel[],
spaces: Space[],
requestIndex: number
): Promise<[Map<string, SpecialNavModel[]>, number]> {
const result = new Map<string, SpecialNavModel[]>()
for (const sp of specials) {
const promises = specials.map(async (sp) => {
const pos = sp.position ?? 'top'
let visible = true
if (sp.visibleIf !== undefined) {
@ -110,8 +116,9 @@
list.push(sp)
result.set(pos, list)
}
}
return result
})
await Promise.all(promises)
return [result, requestIndex]
}
const dispatch = createEventDispatcher()
</script>

View File

@ -28,7 +28,9 @@ export function classIcon (client: Client, _class: Ref<Class<Obj>>): Asset | und
}
export function getSpecialSpaceClass (model: NavigatorModel): Array<Ref<Class<Space>>> {
const spaceResult = model.spaces.map((x) => x.spaceClass)
const result = (model.specials ?? []).map((it) => it.spaceClass).filter((it) => it !== undefined)
const result = (model.specials ?? [])
.map((it) => it.spaceClass)
.filter((it) => it !== undefined && !spaceResult.includes(it))
return spaceResult.concat(result as Array<Ref<Class<Space>>>)
}