import { App } from "../App/App";
import { GitHubSearchStream } from "./GitHubSearchStream";
import { OSNotice } from "../Notice/OSNotice";
import { from } from "fromfrom";
import { UnionQuery } from "../GitHubSearchList/queries/QueryRole";

/**
 * Create OS Notices from updated Streams.
 * @param app
 * @param query
 * @param firstStream
 * @param lastStream
 */
export const createOSNoticesFromStreams = ({
    app,
    query,
    firstStream,
    lastStream
}: {
    app: App;
    query: UnionQuery;
    firstStream?: GitHubSearchStream;
    lastStream?: GitHubSearchStream;
}): OSNotice[] => {
    // Notice updated results
    // First results is ignored
    if (!lastStream || !firstStream) 

    if (!firstStream.hasResultAtLeastOne) {
        return [];
    }
    const diff = lastStream.itemSortedCollection.differenceCollection(
        firstStream.itemSortedCollection
    );
    return from(diff.items)
        .filter(item => {
            return app.user.activity.notificationActity.timeStamp < item.updatedAtDate.getTime();
        })
        .sortBy(item => {
            return item.updated_at;
        })
        .map(item => {
            return new OSNotice({
                title: item.title,
                body: item.body || "",
                subTitle: item.shortPath,
                icon: item.avatarUrl,
                refs: {
                    query: query,
                    item: item
                }
            });
        })
        .toArray();
};

{
        return [];
    }