diff --git a/src/LoadHistory.test.ts b/src/LoadHistory.test.ts
index 920c6b8..58062ed 100644
--- a/src/LoadHistory.test.ts
+++ b/src/LoadHistory.test.ts
@@ -179,7 +179,7 @@ describe('generateRelaysChanges', () => {
],
} as Kind10002Event,
]);
- expect(r[0].changes).toEqual(['
added wss://brando-relay1.com write only
']);
+ expect(r[0].changes).toEqual(['added wss://brando-relay1.com as write only
']);
});
test('when a relay is removed, the removal is listed in the changes array', () => {
const r = generateRelayChanges([
@@ -199,9 +199,9 @@ describe('generateRelaysChanges', () => {
],
} as Kind10002Event,
]);
- expect(r[0].changes).toEqual(['removed wss://brando-relay1.com write only
']);
+ expect(r[0].changes).toEqual(['removed wss://brando-relay1.com which was write only
']);
});
- test('when a relay is modified, the removal is listed in the changes array', () => {
+ test('when a relay is modified, the modification is listed in the changes array', () => {
const r = generateRelayChanges([
{
...SampleEvents.kind10002,
@@ -218,7 +218,7 @@ describe('generateRelaysChanges', () => {
],
} as Kind10002Event,
]);
- expect(r[0].changes).toEqual(['modified wss://brando-relay.com read only
']);
+ expect(r[0].changes).toEqual(['modified wss://brando-relay.com to read instead of write
']);
});
test('when a contact is added and another removed, both events are listed in the changes array', () => {
const r = generateRelayChanges([
@@ -238,8 +238,8 @@ describe('generateRelaysChanges', () => {
} as Kind10002Event,
]);
expect(r[0].changes).toEqual([
- 'added wss://brando-relay1.com write only
',
- 'removed wss://alicerelay.example.com
',
+ 'added wss://brando-relay1.com as write only
',
+ 'removed wss://alicerelay.example.com which was read and write
',
]);
});
});
diff --git a/src/LoadHistory.ts b/src/LoadHistory.ts
index 4cdb263..18bd37b 100644
--- a/src/LoadHistory.ts
+++ b/src/LoadHistory.ts
@@ -123,11 +123,20 @@ export const generateRelayChanges = (
if (i === a.length - 1) e.tags.forEach((r) => changes.push(summariseRelay(r)));
else {
const next = a[i + 1].tags;
+ const relayReadAndWrite = (r:Kind10002Tag, addedorremoveed: 'added' | 'removed'): string => {
+ const wonly = `write`;
+ const ronly = `read`;
+ const randw = `${ronly} and ${wonly}`;
+ if (!r[2]) return randw;
+ if (r[2] === 'write') return `${wonly} only`;
+ return `${ronly} only`;
+ };
+
// list adds
const added = current.filter((c) => !next.some((n) => n[1] === c[1]));
if (added.length > 0) {
added.forEach((r) => changes.push(
- `added ${summariseRelay(r)}
`,
+ `added ${r[1]} as ${relayReadAndWrite(r, 'added')}
`,
));
}
// list modified
@@ -135,15 +144,25 @@ export const generateRelayChanges = (
(c) => next.filter((n) => n[1] === c[1]).some((n) => c[2] !== n[2]),
);
if (modified.length > 0) {
- modified.forEach((r) => changes.push(
- `modified ${summariseRelay(r)}
`,
- ));
+ modified.forEach((r) => {
+ const nv = next.find((n) => n[1] === r[1]);
+ let s: string;
+ if (!r[2]) {
+ if (!!nv && nv[2] === 'read') s = 'write as well as read';
+ else s = 'read as well as write';
+ } else if (r[2] === 'read') {
+ if (!nv) s = 'only read and no longer write';
+ else s = 'read instead of write';
+ } else if (!nv) s = 'only write and no longer read';
+ else s = 'write instead of read';
+ changes.push(`modified ${r[1]} to ${s}
`);
+ });
}
// list deletes
const removed = next.filter((c) => !current.some((n) => n[1] === c[1]));
if (removed.length > 0) {
removed.forEach((r) => changes.push(
- `removed ${summariseRelay(r)}
`,
+ `removed ${r[1]} which was ${relayReadAndWrite(r, 'removed')}
`,
));
}
}
diff --git a/src/style.scss b/src/style.scss
index 8884a05..567d4ee 100644
--- a/src/style.scss
+++ b/src/style.scss
@@ -51,10 +51,10 @@ img[src=""] {
max-width:150px;
}
}
-.added mark {
+.added mark, mark.added {
background-color:rgb(29, 255, 116)
}
-.removed mark {
+.removed mark, mark.removed {
background-color:rgb(255, 125, 125)
}