2022-02-23 13:52:06 +00:00
|
|
|
import {log} from './logging.js';
|
|
|
|
import {querySelectorAll} from './query-selectors.js';
|
2020-10-10 23:32:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tries to extract and save the groups. Returns the current saved groups when
|
|
|
|
* the user is not in `/groups` and the new ones when they are in `/groups`.
|
|
|
|
*/
|
2022-02-23 13:52:06 +00:00
|
|
|
export function extractGroups(): string[] | undefined {
|
2020-10-10 23:32:27 +00:00
|
|
|
if (window.location.pathname !== '/groups') {
|
|
|
|
log('Not in "/groups", returning early.');
|
2022-02-23 13:52:06 +00:00
|
|
|
return;
|
2020-10-10 23:32:27 +00:00
|
|
|
}
|
|
|
|
|
2022-02-23 13:52:06 +00:00
|
|
|
return querySelectorAll('.link-group').map(
|
|
|
|
(value) => value.textContent ?? '<unknown group>',
|
2020-10-10 23:32:27 +00:00
|
|
|
);
|
|
|
|
}
|