package Ġcom . em og oth . android . phone . m imi . db . dao Ċ Ċ import Ġandroidx . room . Dao Ċ import Ġandroidx . room . Query Ċ import Ġcom . em og oth . android . phone . m imi . db . M imi Database Ċ import Ġcom . em og oth . android . phone . m imi . db . models . History Ċ import Ġio . reactivex . Flow able Ċ import Ġio . reactivex . Single Ċ Ċ @ Dao Ċ abstract Ġclass ĠHistory Access Ġ: ĠBase Dao < History >() Ġ{ ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . THREAD _ ID } Ġ= Ġ: thread Id ĠAND Ġ${ History . BOARD _ NAME } Ġ= Ġ: board Name ") ĊĠĠĠ Ġabstract Ġfun Ġget History By Thread ( board Name : ĠString , Ġthread Id : ĠLong ): ĠFlow able < History > ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE }") ĊĠĠĠ Ġabstract Ġfun ĠgetAll (): ĠFlow able < List < History >> Ċ Ċ // ĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . THREAD _ RE MOVED } Ġ= Ġ 0 ĠAND Ġ(${ History . ACTIVE } Ġ= Ġ 1 ĠOR Ġ${ History . WATCH ED } Ġ= Ġ 1 ) ĠORDER ĠBY Ġ${ History . LAST _ ACCESS } ĠASC ĠLIMIT Ġ 1 ") Ċ // ĠĠĠ Ġabstract Ġfun Ġoldest Active History (): ĠSingle < History > ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . THREAD _ RE MOVED } Ġ= Ġ 0 ĠAND Ġ${ History . WATCH ED } Ġ= Ġ 1 ĠORDER ĠBY Ġ${ History . LAST _ ACCESS } ĠASC ĠLIMIT Ġ 1 ") ĊĠĠĠ Ġabstract Ġfun Ġoldest Active Bookmark (): ĠSingle < History > ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . WATCH ED } Ġ= Ġ 0 ĠORDER ĠBY Ġ${ History . ORDER _ ID } ĠLIMIT Ġ: count ") ĊĠĠĠ Ġabstract Ġfun Ġget History ( count : ĠInt ): ĠFlow able < List < History >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . WATCH ED } Ġ= Ġ 1 ĠORDER ĠBY Ġ${ History . ORDER _ ID } ĠLIMIT Ġ: count ") ĊĠĠĠ Ġabstract Ġfun Ġget Book marks ( count : ĠInt ): ĠFlow able < List < History >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . WATCH ED } Ġ= Ġ 0 ĠORDER ĠBY Ġ${ History . ORDER _ ID }") ĊĠĠĠ Ġabstract Ġfun Ġget History (): ĠFlow able < List < History >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . WATCH ED } Ġ= Ġ 1 ĠORDER ĠBY Ġ${ History . ORDER _ ID }") ĊĠĠĠ Ġabstract Ġfun Ġget Book marks (): ĠFlow able < List < History >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . THREAD _ RE MOVED } Ġ= Ġ 0 ĠLIMIT Ġ: count ") ĊĠĠĠ Ġabstract Ġfun ĠgetAll Active ( count : ĠInt Ġ= Ġ 9 9 9 9 ): ĠFlow able < List < History >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . WATCH ED } Ġ= Ġ 0 ĠAND Ġ${ History . THREAD _ RE MOVED } Ġ= Ġ 0 ĠORDER ĠBY Ġ${ History . ORDER _ ID } ĠLIMIT Ġ: count ") ĊĠĠĠ Ġabstract Ġfun Ġget Active History ( count : ĠInt Ġ= Ġ 9 9 9 9 ): ĠFlow able < List < History >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . WATCH ED } Ġ= Ġ 0 ĠAND Ġ${ History . THREAD _ RE MOVED } Ġ= Ġ 0 ĠORDER ĠBY Ġ${ History . ORDER _ ID }") ĊĠĠĠ Ġabstract Ġfun Ġget Active History (): ĠFlow able < List < History >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . WATCH ED } Ġ= Ġ 1 ĠAND Ġ${ History . THREAD _ RE MOVED } Ġ= Ġ 0 ĠORDER ĠBY Ġ${ History . ORDER _ ID } ĠLIMIT Ġ: count ") ĊĠĠĠ Ġabstract Ġfun Ġget Active Book marks ( count : ĠInt ): ĠFlow able < List < History >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . WATCH ED } Ġ= Ġ 1 ĠAND Ġ${ History . THREAD _ RE MOVED } Ġ= Ġ 0 ĠORDER ĠBY Ġ${ History . ORDER _ ID }") ĊĠĠĠ Ġabstract Ġfun Ġget Active Book marks (): ĠFlow able < List < History >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠORDER ĠBY Ġ${ History . LAST _ ACCESS } ĠDESC ") ĊĠĠĠ Ġabstract Ġfun ĠgetAll By Last Access (): ĠFlow able < List < History >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . LAST _ ACCESS } Ġ< Ġ: timestamp ĠAND Ġ${ History . WATCH ED } Ġ= Ġ: w atched ĠORDER ĠBY Ġ${ History . LAST _ ACCESS } ĠDESC ") ĊĠĠĠ Ġabstract Ġfun Ġget Old History ( timestamp : ĠLong , Ġw atched : ĠBoolean ): ĠSingle < List < History >> ĊĊĠĠĠ Ġ@ Query (" UPDATE Ġ${ M imi Database . HISTORY _ TABLE } ĠSET Ġ${ History . WATCH ED } Ġ= Ġ: w atched ĠWHERE Ġ${ History . THREAD _ ID } Ġ= Ġ: thread Id ĠAND Ġ${ History . BOARD _ NAME } Ġ= Ġ: board Name ") ĊĠĠĠ Ġabstract Ġfun Ġw atched ( board Name : ĠString , Ġthread Id : ĠLong , Ġw atched : ĠBoolean ): ĠSingle < Int > ĊĊĠĠĠ Ġ@ Query (" UPDATE Ġ${ M imi Database . HISTORY _ TABLE } ĠSET Ġ${ History . UN READ _ COUNT } Ġ= Ġ: count ĠWHERE Ġ${ History . THREAD _ ID } Ġ= Ġ: thread Id ĠAND Ġ${ History . BOARD _ NAME } Ġ= Ġ: board Name ") ĊĠĠĠ Ġabstract Ġfun Ġunread Count ( board Name : ĠString , Ġthread Id : ĠLong , Ġcount : ĠInt ): ĠSingle < Int > ĊĊĠĠĠ Ġ@ Query (" UPDATE Ġ${ M imi Database . HISTORY _ TABLE } ĠSET Ġ${ History . LAST _ ACCESS } Ġ= Ġ: timestamp ĠWHERE Ġ${ History . THREAD _ ID } Ġ= Ġ: thread Id ĠAND Ġ${ History . BOARD _ NAME } Ġ= Ġ: board Name ") ĊĠĠĠ Ġabstract Ġfun Ġlast Ac cessed ( board Name : ĠString , Ġthread Id : ĠLong , Ġtimestamp : ĠLong ): ĠSingle < Int > ĊĊĠĠĠ Ġ@ Query (" UPDATE Ġ${ M imi Database . HISTORY _ TABLE } ĠSET Ġ${ History . LAST _ READ _ POS } Ġ= Ġ: position ĠWHERE Ġ${ History . THREAD _ ID } Ġ= Ġ: thread Id ĠAND Ġ${ History . BOARD _ NAME } Ġ= Ġ: board Name ") ĊĠĠĠ Ġabstract Ġfun Ġlast Read Pos ( board Name : ĠString , Ġthread Id : ĠLong , Ġposition : ĠInt ): ĠSingle < Int > ĊĊĠĠĠ Ġ@ Query (" UPDATE Ġ${ M imi Database . HISTORY _ TABLE } ĠSET Ġ${ History . THREAD _ RE MOVED } Ġ= Ġ: removed ĠWHERE Ġ${ History . BOARD _ NAME } Ġ= Ġ: board Name ĠAND Ġ${ History . THREAD _ ID } Ġ= Ġ: thread Id ") ĊĠĠĠ Ġabstract Ġfun Ġthread Removed ( board Name : ĠString , Ġthread Id : ĠLong , Ġremoved : ĠBoolean ): ĠSingle < Int > Ċ Ċ // ĠĠĠ Ġ@ Query (" UPDATE Ġ${ M imi Database . HISTORY _ TABLE } ĠSET Ġ${ History . ACTIVE } Ġ= Ġ: active ĠWHERE Ġ${ History . BOARD _ NAME } Ġ= Ġ: board Name ĠAND Ġ${ History . THREAD _ ID } Ġ= Ġ: thread Id ") Ċ // ĠĠĠ Ġabstract Ġfun Ġthread Active ( board Name : ĠString , Ġthread Id : ĠLong , Ġactive : ĠBoolean ): ĠSingle < Int > ĊĊĠĠĠ Ġ@ Query (" UPDATE Ġ${ M imi Database . HISTORY _ TABLE } ĠSET Ġ${ History . SIZE } Ġ= Ġ: size ĠWHERE Ġ${ History . BOARD _ NAME } Ġ= Ġ: board Name ĠAND Ġ${ History . THREAD _ ID } Ġ= Ġ: thread Id ") ĊĠĠĠ Ġabstract Ġfun Ġthread Size ( board Name : ĠString , Ġthread Id : ĠLong , Ġsize : ĠInt ): ĠSingle < Int > ĊĊĠĠĠ Ġ@ Query (" UPDATE Ġ${ M imi Database . HISTORY _ TABLE } ĠSET Ġ${ History . ORDER _ ID } Ġ= Ġ: order ĠWHERE Ġ${ History . BOARD _ NAME } Ġ= Ġ: board Name ĠAND Ġ${ History . THREAD _ ID } Ġ= Ġ: thread Id ") ĊĠĠĠ Ġabstract Ġfun Ġorder ( board Name : ĠString , Ġthread Id : ĠLong , Ġorder : ĠInt ): ĠSingle < Int > ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . LAST _ ACCESS } Ġ< Ġ: timestamp ĠAND Ġ${ History . WATCH ED } Ġ= Ġ: w atched ") ĊĠĠĠ Ġabstract Ġfun Ġprune ( timestamp : ĠLong , Ġw atched : ĠBoolean ) ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM Ġ${ M imi Database . HISTORY _ TABLE } ĠWHERE Ġ${ History . BOARD _ NAME } Ġ= Ġ: board Name ĠAND Ġ${ History . THREAD _ ID } Ġ= Ġ: thread Id ") ĊĠĠĠ Ġabstract Ġfun Ġremove Thread ( board Name : ĠString , Ġthread Id : ĠLong ) ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM Ġ${ M imi Database . HISTORY _ TABLE }") ĊĠĠĠ Ġabstract Ġfun Ġclear () Ċ }