Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #144 from orbitdb/feat/weekly-channel
Browse files Browse the repository at this point in the history
Move from one default channel to weekly channels
  • Loading branch information
JaniAnttonen authored Nov 18, 2019
2 parents 80dab14 + 29361b0 commit 7219b49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/stores/NetworkStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ChannelStore from './ChannelStore'

import Logger from '../utils/logger'
import WorkerProxy from '../utils/worker-proxy'
import { createWeeklyChannelName } from '../utils/channels'

configure({ enforceActions: 'observed' })

Expand Down Expand Up @@ -63,7 +64,7 @@ export default class NetworkStore {
swarmPeers = []

@observable
defaultChannels = window.location.href.match('localhost:') ? ['orbit-dev'] : ['orbit']
defaultChannels = window.location.href.match('localhost:') ? [createWeeklyChannelName('orbit-dev')] : [createWeeklyChannelName('orbit')]

// Public instance getters

Expand Down
9 changes: 9 additions & 0 deletions src/utils/channels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import getWeek from 'date-fns/getWeek'
import getYear from 'date-fns/getYear'

export function createWeeklyChannelName (channelName) {
const now = Date.now()
const year = getYear(now)
const week = getWeek(now)
return channelName + '-' + year + '-' + week
}

0 comments on commit 7219b49

Please sign in to comment.