mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-16 23:33:48 +08:00
feat(feishu): hide archived sessions by default (/archived on to reveal)
This commit is contained in:
parent
961dd5503d
commit
10fd429852
3 changed files with 14 additions and 8 deletions
File diff suppressed because one or more lines are too long
|
|
@ -7,7 +7,7 @@ const EMPTY_STATE = Object.freeze({
|
||||||
seenMessageIds: [],
|
seenMessageIds: [],
|
||||||
watches: {},
|
watches: {},
|
||||||
chatTargets: {},
|
chatTargets: {},
|
||||||
includeArchivedSessions: true,
|
includeArchivedSessions: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
/** One conversation key may watch at most this many sessions. */
|
/** One conversation key may watch at most this many sessions. */
|
||||||
|
|
@ -41,7 +41,7 @@ export class StateStore {
|
||||||
chatTargets: parsed.chatTargets && typeof parsed.chatTargets === 'object' ? parsed.chatTargets : {},
|
chatTargets: parsed.chatTargets && typeof parsed.chatTargets === 'object' ? parsed.chatTargets : {},
|
||||||
includeArchivedSessions: typeof parsed.includeArchivedSessions === 'boolean'
|
includeArchivedSessions: typeof parsed.includeArchivedSessions === 'boolean'
|
||||||
? parsed.includeArchivedSessions
|
? parsed.includeArchivedSessions
|
||||||
: true,
|
: false,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error?.code !== 'ENOENT') throw error;
|
if (error?.code !== 'ENOENT') throw error;
|
||||||
|
|
@ -161,11 +161,11 @@ export class StateStore {
|
||||||
// ── Session-list archived policy (per bot) ───────────────────────────────
|
// ── Session-list archived policy (per bot) ───────────────────────────────
|
||||||
|
|
||||||
includesArchivedSessions() {
|
includesArchivedSessions() {
|
||||||
return this.#state.includeArchivedSessions !== false;
|
return this.#state.includeArchivedSessions === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setIncludeArchivedSessions(include) {
|
async setIncludeArchivedSessions(include) {
|
||||||
this.#state.includeArchivedSessions = include !== false;
|
this.#state.includeArchivedSessions = include === true;
|
||||||
await this.#persist();
|
await this.#persist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2544,7 +2544,7 @@ test('reconnect compensation replays missed turn/end and dedups duplicates', asy
|
||||||
assert.match(JSON.stringify(cards[1]), /watched-session/);
|
assert.match(JSON.stringify(cards[1]), /watched-session/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('/archived off hides archived sessions from the list and watch index', async () => {
|
test('archived sessions are hidden by default; /archived on reveals them', async () => {
|
||||||
const { state } = await watchStoreFixture();
|
const { state } = await watchStoreFixture();
|
||||||
const work = join(tmpdir(), 'dsh-im-archived-test-work');
|
const work = join(tmpdir(), 'dsh-im-archived-test-work');
|
||||||
mkdirSync(work, { recursive: true });
|
mkdirSync(work, { recursive: true });
|
||||||
|
|
@ -2571,8 +2571,7 @@ test('/archived off hides archived sessions from the list and watch index', asyn
|
||||||
});
|
});
|
||||||
bridge._sent = sent;
|
bridge._sent = sent;
|
||||||
|
|
||||||
await bridge.accept(event('archived-off', '/archived off', { senderOpenId: 'ou_owner' }));
|
// Default: hidden. The explicit toggle re-enables inclusion for the card check.
|
||||||
await bridge.waitForIdle();
|
|
||||||
assert.equal(state.includesArchivedSessions(), false);
|
assert.equal(state.includesArchivedSessions(), false);
|
||||||
|
|
||||||
await bridge.accept(event('sessions-arch', '/sessionlist', { senderOpenId: 'ou_owner' }));
|
await bridge.accept(event('sessions-arch', '/sessionlist', { senderOpenId: 'ou_owner' }));
|
||||||
|
|
@ -2585,4 +2584,11 @@ test('/archived off hides archived sessions from the list and watch index', asyn
|
||||||
await bridge.waitForIdle();
|
await bridge.waitForIdle();
|
||||||
assert.ok(state.watchEntry('p2p:ou_owner', 'live-session'));
|
assert.ok(state.watchEntry('p2p:ou_owner', 'live-session'));
|
||||||
assert.equal(state.watchEntry('p2p:ou_owner', 'old-session'), null);
|
assert.equal(state.watchEntry('p2p:ou_owner', 'old-session'), null);
|
||||||
|
|
||||||
|
await bridge.accept(event('archived-on', '/archived on', { senderOpenId: 'ou_owner' }));
|
||||||
|
await bridge.waitForIdle();
|
||||||
|
await bridge.accept(event('sessions-arch-2', '/sessionlist', { senderOpenId: 'ou_owner' }));
|
||||||
|
await bridge.waitForIdle();
|
||||||
|
const useOn = useActionsFromCard(cards.at(-1));
|
||||||
|
assert.deepEqual(useOn, ['live-session', 'old-session'], '/archived on restores archived sessions');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue