Add ability to export and import followers with settings #121
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { getFollows } from '@/settingsManager';
|
||||
import { ref } from 'vue'
|
||||
|
||||
export default {
|
||||
@ -33,13 +34,11 @@ export default {
|
||||
* @returns true if streamer was followed, false if streamer was already followed.
|
||||
*/
|
||||
followStreamer(username: string): boolean {
|
||||
const follows = localStorage.getItem('following') || '[]'
|
||||
let parsedFollows: string[] = JSON.parse(follows)
|
||||
let follows = getFollows()
|
||||
if (follows.includes(username)) return false
|
||||
|
||||
if (parsedFollows.includes(username)) return false
|
||||
|
||||
parsedFollows.push(username)
|
||||
localStorage.setItem('following', JSON.stringify(parsedFollows))
|
||||
follows.push(username)
|
||||
localStorage.setItem('following', JSON.stringify(follows))
|
||||
return true
|
||||
},
|
||||
|
||||
@ -49,13 +48,12 @@ export default {
|
||||
* @returns true if unfollowed, false if not followed.
|
||||
*/
|
||||
unfollowStreamer(username: string): boolean {
|
||||
const follows = localStorage.getItem('following') || '[]'
|
||||
let parsedFollows: string[] = JSON.parse(follows)
|
||||
let follows = getFollows()
|
||||
|
||||
const index = parsedFollows.indexOf(username)
|
||||
const index = follows.indexOf(username)
|
||||
if (index === -1) return false
|
||||
parsedFollows.splice(index, 1)
|
||||
localStorage.setItem('following', JSON.stringify(parsedFollows))
|
||||
follows.splice(index, 1)
|
||||
localStorage.setItem('following', JSON.stringify(follows))
|
||||
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user